您的位置:首页 > 其它

158B - Taxi

2015-05-21 15:41 309 查看
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int cnt[5];

int main() {

    memset(cnt, 0, sizeof(cnt));
    int n, x;
    int ans = 0;
    scanf("%d", &n);
    for(int i = 0; i < n; ++i) {
        scanf("%d", &x);
        cnt[x]++;
    }
    ans += cnt[4];
    ans += cnt[3];
    cnt[1] -= min(cnt[1], cnt[3]);
    ans += cnt[2]/2;
    int t = (cnt[2]%2)*2 + cnt[1];
    ans += (t/4)+(t%4!=0);
    cout << ans << endl;
    return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: