CSES - HIIT Open 2016 - Results
Submission details
Task:Cent saving
Sender:zah
Submission time:2016-05-28 13:08:29 +0300
Language:C++
Status:READY
Result:
Test results
testverdicttime
#10.06 sdetails
#20.06 sdetails

Code

#include <iostream>

using namespace std;

//ios_base::sync_with_stdio(0);
//cin.tie(0);


int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    long long t;
    cin >> t;
    long long n;
    long long x;
    long long modulo;
    long long kol;
    long long nel;
    long long summa;
    long long tmp;
    /*int alkuluvut[1001] = {};
    alkuluvut[1] = 1;
    for(int i=2; i<100; i++) {
        for(int j=i*i; j<1001; j+=i) alkuluvut[j]=1; 
    } */   

    
    for(int i=0; i<t; i++) {
        cin >> n;
        summa = 0;
        kol = 0;
        nel = 0;
        for(int j=0; j<n; j++) {
            cin >> x;
            summa += x;
            modulo = x%5;
            if(modulo<3) {
                summa -= modulo;
                continue;
            } else {
                if(modulo==4) { 
                    nel += 1;    
                } else kol += 1;    
            }
        }
        tmp = min(kol,nel);
        summa -= 2*tmp;
        kol -= tmp;
        nel -= tmp;
        if(kol==0) {
        summa -= 2*nel/3;
        summa += nel%3 ;
        } else {
            summa -= kol/2;
            summa += kol%2*2;
        }
        cout << summa << "\n";
    }
}



Test details

Test 1

Verdict:

input
100
1000
528433894 255789530 559301042 ...

correct output
475191144965
460688647850
478543444030
475238936090
456736521510
...

user output
475191144965
460688647850
478543444029
475238936090
456736521510
...

Test 2

Verdict:

input
1
100000
666086355 190481330 514353517 ...

correct output
47176864928795

user output
47176864928794