CSES - Practice Contest 2024 - Results
Submission details
Task:Cent saving
Sender:\(._.)/
Submission time:2024-09-28 13:37:53 +0300
Language:C++ (C++11)
Status:READY
Result:
Test results
testverdicttime
#10.05 sdetails
#20.05 sdetails

Code

// Online C++ compiler to run C++ program online
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
using namespace std;
int main() {
    int t;
    cin >> t;
    
    for (int test = 0; test < t; test++)
    {
        int n;
        cin >> n;
        
        int sum = 0;
        int a1 = 0;
        int a2 = 0;
        for (int i = 0; i < n; i++)
        {
            int x;
            cin >> x;
            sum += (x/5)*5;
            x = x % 5;
        
            if (x == 3)
                a2 += 1;
            if (x == 4)
                a1 += 1;
        }
    
        
    
        sum += (a2 / 2) * 5;
        a2 = a2 % 2;
        sum += (a1 / 3) * 10;
        a1 = a1 % 3;
    
        if (a2 == 0)
            sum += a1 * 4;
        else
            sum += ( (a1 * 3 + a2 * 4) / 5 ) * 5;
    
        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
-1550224741
1127147321
1802074339
-1502433611
1469988302
...
Truncated

Test 2

Verdict:

input
1
100000
666086355 190481330 514353517 ...

correct output
47176864928795

user output
944166176