CSES - HIIT Open 2016 - Results
Submission details
Task:Cent saving
Sender:Oispa Kaljaa
Submission time:2016-05-28 13:12:09 +0300
Language:C++
Status:READY
Result:
Test results
testverdicttime
#10.05 sdetails
#20.05 sdetails

Code

#include <bits/stdc++.h>

using namespace std;

int main(){
  cin.sync_with_stdio(0);
  cin.tie(0);
  
  int tests; cin >> tests;
  int p[101010];
  while(tests--){
    int n; cin >> n;
    int sum = 0;
    for(int i = 0; i < n; i++){
      cin >> p[i];
      sum+=p[i];
    }
    int c[5] = {0};
    
    for(int i = 0; i < n; i++)
      c[p[i]%5]++;
    int mi34 = min(c[3], c[4]);
    sum-=2*mi34;
    c[3]-=mi34;
    c[4]-=mi34;
    
    sum-=(c[4]/3)*2;
    c[4]-=c[4]/3;
    sum+=c[4];
    
    sum-=(c[3]/2);
    c[3]-=c[3]/2;
    sum+=c[3]*2;
    
    sum-=2*c[2];
    sum-=c[1];
    
    cout << sum << endl;
  }
    
    
  return 0;
}

Test details

Test 1

Verdict:

input
100
1000
528433894 255789530 559301042 ...

correct output
475191144965
460688647850
478543444030
475238936090
456736521510
...

user output
-1550224879
1127147188
1802074186
-1502433746
1469988142
...
Truncated

Test 2

Verdict:

input
1
100000
666086355 190481330 514353517 ...

correct output
47176864928795

user output
944149703