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 12:12:16
2016-05-28 12:11:29
Task:Cent saving
Sender:Game of Nolife
Submission time:2016-05-28 12:12:16
Status:READY
Result:ACCEPTED

Show test data

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