Code Submission Evaluation System Login

HIIT Open 2016

 Start: 2016-05-28 11:00:00 End: 2016-05-28 16:00:00

CSES - HIIT Open 2016 - Results
History
2016-05-28 13:16:35
 Task: Cent saving Sender: Anonyymit Algoritmistit Submission time: 2016-05-28 13:16:35 Language: C++ Status: READY Result: ACCEPTED

Test results

 test verdict time (s) #1 ACCEPTED 0.14 / 1.00 details #2 ACCEPTED 0.13 / 1.00 details

Code

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);

ll t;
cin >> t;

for(int i = 0; i<t; i++) {

ll n;
cin >> n;

unordered_map<ll,ll> arvot;

ll saasto = 0;
ll summahinnoista = 0;

for(int j = 0; j < n; j++) {
ll x;
cin >> x;
summahinnoista += x;
stringstream s;
s << x;
string lol;
s >> lol;

arvot[(lol[lol.length()-1]-'0')]++;

}

saasto += arvot[2]*2;
saasto += arvot[7]*2;
saasto += arvot[1];
saasto += arvot[6];

ll miinusykkoset = arvot[4] + arvot[9];
ll miinuskakkoset = arvot[3] + arvot[8];

ll best = min(miinuskakkoset, miinusykkoset);

saasto += best * 2;
miinuskakkoset -= best;
miinusykkoset -= best;

saasto += floor(miinusykkoset / 3) * 2;
saasto += floor(miinuskakkoset / 2);

saasto -= miinusykkoset % 3;
saasto -= (miinuskakkoset % 2) * 2;

cout << (summahinnoista-saasto) << endl;
}

}

Test details

Test 1

Verdict: ACCEPTED

input
100
1000
528433894 255789530 559301042 ...
view   save

correct output
475191144965
460688647850
478543444030
475238936090
456736521510
477687545180
464978309415
469754811210
473772861015
459378192990
484964363025
469227939745
476076446280
463968012420
480317542525
458834989560
472694971870
467845191980
475238640235
470940911790
...
view   save

user output
475191144965
460688647850
478543444030
475238936090
456736521510
477687545180
464978309415
469754811210
473772861015
459378192990
484964363025
469227939745
476076446280
463968012420
480317542525
458834989560
472694971870
467845191980
475238640235
470940911790
...
view   save

Test 2

Verdict: ACCEPTED

input
1
100000
666086355 190481330 514353517 ...
view   save

correct output
47176864928795
view   save

user output
47176864928795
view   save