Codeforces VK Cup 2012 Qualification Round 1, problem: (B) Taxi solution: http://ideone.com/M7gmFE
#include <iostream> #include <cstdio> using namespace std; int main() { int n, s, a[5]={0}, r; r=0; scanf("%d", &n); while(n--) scanf("%d", &s), a[s]++; r=a[4]+a[3]; a[1]-=a[3]; r+=a[2]*2/4; if(a[2]%2==1) { r++; a[1]-=2; } if(a[1]>0) { r+=a[1]/4; if(a[1]%4>0) r++; } printf("%d", r); return 0; }
note: if taxi doesnt contain more than 4 or eqauls to 4 then you can increment passenger number
No comments:
Post a Comment