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 16:44:55
2016-05-28 16:43:21
2016-05-28 16:39:47
2016-05-28 15:07:52
2016-05-28 14:46:10
2016-05-28 14:43:32
2016-05-28 14:29:42
2016-05-28 14:01:36
2016-05-28 13:44:58
Task:Cent saving
Sender:ContinuedLife
Submission time:2016-05-28 15:07:52
Status:READY
Result:WRONG ANSWER

Show test data

Code

#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0), cout.precision(6);

using namespace std;

bool mycomp(int a, int b){
	return a > b;
}

int main(){ _
	int TC;	cin >> TC;
	while(TC--){
		int n,sum = 0, num;	cin >> n;

		int n1 = 0, n2 = 0, save = 0;
		for(int i = 0; i < n; ++i){
			cin >> num;
			sum += num;
			num %= 5;
			switch(num){
				case 0:	num = 0;	break;
				case 1:	num = -1;	break;
				case 2:	num = -2;	break;
				case 3:	num = 2;	break;
				case 4:	num = 1;	break;
			}
			if(num == 1)	n1 += 1;
			if(num == 2)	n2 += 1;
			if(num <= 0)	save += num;
		}

		int minN = min(n1, n2);
		save += -2 * minN;
		n1 -= minN;	n2 -= minN;

		if(n1 != 0){
			int beishu = n1 / 3;
			save += -2*beishu + n1%3;
		} else {
			int beishu = n2/ 2;
			save += -1 * beishu + n2%2*2;
		}

		cout << sum + save << endl;
	}
	return 0;
}