CSES - HIIT Open 2016 - Results
Submission details
Task:Cent saving
Sender:Barely Div 1
Submission time:2016-05-28 12:13:37 +0300
Language:C++
Status:READY
Result:ACCEPTED
Test results
testverdicttime
#1ACCEPTED0.08 sdetails
#2ACCEPTED0.08 sdetails

Code

#include <iostream>
#include <cstdio>
#include <iomanip>
#include <vector>

using namespace std;

int main() {
	int t, n;
	cin >> t;

	for(int i=0; i<t; i++) {
		cin >> n;
		long long sum=0, p;
		long long save=0, m3=0, m4=0;
		for(int j=0; j<n; j++) {
			cin >> p;
			sum += p;
			switch(p%5) {
				case 0: break;
				case 1: save++; break;
				case 2: save+=2; break;
				case 3: m3++; break;
				case 4: m4++; break;
			}
		}
		int c34 = min(m3, m4);
		save += 2*c34;
		m3 -= c34;
		m4 -= c34;
		save += m3/2;
		save -= 2*(m3&1);
		save += 2*(m4/3);
		save -= m4%3;
		cout << sum-save << endl;
	}

	return 0;
}

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