Task: | Cent saving |
Sender: | Noname 01 |
Submission time: | 2016-05-28 12:38:26 +0300 |
Language: | C++ |
Status: | READY |
Result: | ACCEPTED |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.06 s | details |
#2 | ACCEPTED | 0.06 s | details |
Code
// NONAME-01 #include <bits/stdc++.h> using namespace std; vector<long long> a; long long c[5]; long long total; int n; void Load() { cin >> n; a.resize(n); total = 0; memset(c, 0, sizeof(c)); for (int i = 0; i < n; i++) { cin >> a[i]; total += a[i]; c[a[i] % 5]++; } } void Solve() { long long sav = 0; // c0 ignore; // c1 -> save 1; // c2 -> save 2; //cerr << "total = " << total << "\n"; sav += c[1]; sav += 2*c[2]; sav -= 2*c[3]; sav -= c[4]; //cerr << "sav = " << sav << "\n"; // group c[4] and c[3] for +5; long long i = c[4]; if (i > c[3]) i = c[3]; sav += 5*i; c[4] -= i; c[3] -= i; // group c3 together; i = c[3] / 2; sav += 5*i; // group c4 together; i = c[4] / 3; sav += 5*i; //cerr << "sav = " << sav << "\n"; cout << total - sav << "\n"; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); int nt, tt; cin >> nt; for (tt = 0; tt < nt; tt++) { Load(); Solve(); } return 0; }
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 |