CSES - HIIT Open 2016 - Results
Submission details
Task:Cent saving
Sender:Game of Nolife
Submission time:2016-05-28 12:12:16 +0300
Language:C++
Status:READY
Result:ACCEPTED
Test results
testverdicttime
#1ACCEPTED0.05 sdetails
#2ACCEPTED0.05 sdetails

Code

#include <bits/stdc++.h>
#define F first
#define S second
#define X real()
#define Y imag()
using namespace std;
typedef long long ll;
typedef long double ld;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int tcs;
cin>>tcs;
for (int tc=0;tc<tcs;tc++) {
int n;
cin>>n;
int cnt4=0;
int cnt3=0;
ll sum=0;
for (int i=0;i<n;i++) {
ll p;
cin>>p;
sum+=p-(p%5);
if (p%5==3) cnt3++;
if (p%5==4) cnt4++;
}
int parsa=501010;
for (int i=0;2*i<=cnt3;i++) {
int hlp=5*i;
int asd=min(cnt3-2*i,cnt4);
hlp+=5*asd;
hlp+=((cnt4-asd)/3)*10;
hlp+=(cnt3-2*i-asd)*5;
hlp+=((cnt4-asd)%3)*5;
parsa=min(parsa,hlp);
}
cout<<sum+parsa<<"\n";
}
}

Test details

Test 1

Verdict: ACCEPTED

input
100
1000
528433894 255789530 559301042 ...

correct output
475191144965
460688647850
478543444030
475238936090
456736521510
...

user output
475191144965
460688647850
478543444030
475238936090
456736521510
...
Truncated

Test 2

Verdict: ACCEPTED

input
1
100000
666086355 190481330 514353517 ...

correct output
47176864928795

user output
47176864928795