# HIIT Open 2016

 Start: 2016-05-28 11:00:00 End: 2016-05-28 16:00:00

CSES - HIIT Open 2016 - Results
History
2016-05-28 12:53:23
2016-05-28 12:47:23
 Task: Cent saving Sender: LTR Submission time: 2016-05-28 12:53:23 Language: C++ Status: READY Result: ACCEPTED

## Test results

 test verdict time (s) #1 ACCEPTED 0.09 / 1.00 details #2 ACCEPTED 0.08 / 1.00 details

## Code

```#include <iostream>
#include <vector>
#include <cstdio>
#include <string>

int main()
{
int t;
std::cin >> t;
for (int ti = 0; ti < t; ++ti) {
int n;
std::cin >> n;

long long cost = 0;
int threes = 0;
int fours = 0;
for (int ni = 0; ni < n; ++ni) {
long long p;
std::cin >> p;
long long m = p % 5;
switch (m) {
case 0:
case 1:
case 2:
cost += (p - m);
break;
case 3:
cost += (p - m);
threes++;
break;
case 4:
cost += (p - m);
fours++;
break;
}
}

// Prefer 3 + 4
int combos = std::min(threes, fours);
cost += combos * 5;
threes -= combos;
fours -= combos;

// Sum remaining 3
if (threes > 0) {
int m = threes % 2;
int combines = ((threes - m) / 2);
cost += (combines + m) * 5;
}

// sum remaining 4
if (fours > 0) {
int m = fours % 3;
int combines = ((fours - m) / 3);
cost += ((2 *combines) + m) * 5;
}

std::cout << cost << std::endl;
}
}

```

## Test details

### Test 1

Verdict: ACCEPTED

input
```100 1000 528433894 255789530 559301042 ...```
view   save

correct output
```475191144965 460688647850 478543444030 475238936090 456736521510 477687545180 464978309415 469754811210 473772861015 459378192990 484964363025 469227939745 476076446280 463968012420 480317542525 458834989560 472694971870 467845191980 475238640235 470940911790 ...```
view   save

user output
```475191144965 460688647850 478543444030 475238936090 456736521510 477687545180 464978309415 469754811210 473772861015 459378192990 484964363025 469227939745 476076446280 463968012420 480317542525 458834989560 472694971870 467845191980 475238640235 470940911790 ...```
view   save

### Test 2

Verdict: ACCEPTED

input
```1 100000 666086355 190481330 514353517 ...```
view   save

correct output
`47176864928795`
view   save

user output
`47176864928795`
view   save