Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Codeforces Round 158B
- #include <cmath>
- #include <iostream>
- using namespace std;
- int del(int a, int b) {
- return a/b + (a%b>0);
- }
- int main () {
- int n, k, ans, mas[5] = {};
- cin >> n;
- for (int i=0; i<n; i++) {
- cin >> k;
- mas[k] ++;
- }
- ans = mas[4];
- if (mas[3] <= mas[1]) {
- ans += mas[3];
- mas[1] -= mas[3];
- }
- else {
- ans += mas[3];
- mas[1] = 0;
- }
- mas[2] += del(mas[1], 2);
- ans += del(mas[2], 2);
- cout << ans;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement