Task: | Cent saving |
Sender: | asdf |
Submission time: | 2024-09-28 16:17:31 +0300 |
Language: | C++ (C++20) |
Status: | READY |
Result: | ACCEPTED |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.02 s | details |
#2 | ACCEPTED | 0.02 s | details |
Code
#include <bits/stdc++.h> using namespace std; #define int long long const int N = 2e5 + 5; int n, p[N]; int cnt[5]; void solve() { cin >> n; memset(cnt, 0, sizeof cnt); int sum = 0; for (int i = 1; i <= n; i++) { cin >> p[i]; sum += p[i]; cnt[p[i] % 5]++; } int res = 0; int take = min(cnt[3], cnt[4]); for (int t = 0; t <= take; t++) { int ans = 0; ans += t * 2; int f = (cnt[4] - t) / 3; int th = (cnt[3] - t) / 2; ans += -((cnt[4] - t) % 3); ans += -((cnt[3] - t) % 2) * 2; ans += th; ans += f * 2; ans += cnt[1]; ans += cnt[2] * 2; res = max(res, ans); } cout << sum - res << '\n'; } signed main() { cin.tie(0)->sync_with_stdio(0); int t; cin >> t; while (t--) { solve(); } }
Test details
Test 1
Verdict: ACCEPTED
input |
---|
100 1000 528433894 255789530 559301042 ... |
correct output |
---|
475191144965 460688647850 478543444030 475238936090 456736521510 ... |
user output |
---|
475191144965 460688647850 478543444030 475238936090 456736521510 ... Truncated |
Test 2
Verdict: ACCEPTED
input |
---|
1 100000 666086355 190481330 514353517 ... |
correct output |
---|
47176864928795 |
user output |
---|
47176864928795 |