Code Submission Evaluation System Login

CSES - HIIT Open 2016

HIIT Open 2016

Contest start:2016-05-28 11:00:00
Contest end:2016-05-28 16:00:00

Task list | Submit code | Submissions | Messages | Scoreboard | Statistics


History
2016-05-28 13:24:56
2016-05-28 13:08:29
2016-05-28 13:07:18
2016-05-28 13:06:29
Task:Cent saving
Sender:zah
Submission time:2016-05-28 13:24:56
Status:READY
Result:ACCEPTED

Show test data

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;
            } 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";
    }
}