CSES - HIIT Open 2016 - Results
Submission details
Task:Cent saving
Sender:Verto
Submission time:2016-05-28 12:11:30 +0300
Language:Python2
Status:READY
Result:ACCEPTED
Test results
testverdicttime
#1ACCEPTED0.13 sdetails
#2ACCEPTED0.14 sdetails

Code

import sys
def asints(s):
	return [int(x.strip()) for x in s.split()]
def asoneint(s):
	return int(s.strip())
lines = sys.stdin.readlines()

t = asoneint(lines[0])
for i in range(t):
	n = asoneint(lines[1+i*2])
	ps = asints(lines[2+i*2])
	price = 0
	rem3 = 0
	rem4 = 0
	for j in ps:
		a = j % 5
		b = (j // 5) * 5
		price += b
		if a == 3:
			rem3 += 1
		elif a == 4:
			rem4 += 1
	m = min(rem3, rem4)
	price += m * 5
	rem3 -= m
	rem4 -= m
	price += (rem3 // 2) * 5
	if rem3 % 2 == 1:
		price += 5
	price += (rem4 // 3) * 10
	rem4 = rem4 % 3
	price += rem4 * 5
	print price

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