Task: | Cent saving |
Sender: | Ace of Spades |
Submission time: | 2016-05-28 11:55:42 +0300 |
Language: | C++ |
Status: | READY |
Result: | ACCEPTED |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.06 s | details |
#2 | ACCEPTED | 0.06 s | details |
Code
#include<bits/stdc++.h> using namespace std; int main(void) { cin.tie(0); ios_base::sync_with_stdio(false); cout << fixed << setprecision(12); int64_t t; cin >> t; for(;t>0;t--) { int64_t n; cin >> n; int64_t total=0, p0=0, p1=0, p2=0, m2=0, m1=0; for(int64_t i=0;i<n;i++) { int64_t p; cin >> p; if(p%5 == 0) p0++; if(p%5 == 1) p1++; if(p%5 == 2) p2++; if(p%5 == 3) m2++; if(p%5 == 4) m1++; total+=p; } total-=2*p2; total-=p1; if(m2 >= m1) { m2-=m1; total-=2*m1; total-=m2/2; if(m2%2 == 1) total+=2; } else { m1-=m2; total-=2*m2; total-=2*(m1/3); if(m1%3 == 1) { total++; } else if(m1%3 == 2) { total+=2; } } cout << total << '\n'; } 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 |