Đăng nhập để hỏi chi tiết


Hãy luôn nhớ cảm ơn và vote 5*
nếu câu trả lời hữu ích nhé!
/**
* author: tđq
**/
#include <bits/stdc++.h>
#define task ""
using namespace std;
typedef long long ll;
const ll nmax = 1e5 + 5;
ll n, a, d[5], ans = 0;
int main()
{
//freopen(task".inp" , "r" , stdin);
//freopen(task".out" , "w" , stdout);
ios::sync_with_stdio(false);
cin.tie(0);
cin >> n;
d[0] = 100010;
while (n--)
{
cin >> a;
(d[4 - a] > 0) ? ans++, d[4 - a]-- : d[a]++;
}
ans += d[3] + (d[1] + d[2] * 2 + 3) / 4;
cout << ans;
return 0;
}Hãy giúp mọi người biết câu trả lời này thế nào?
Bảng tin