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

Code

#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;

int main () {
  int t;
  cin>>t;
  for (int u = 0; u < t; u++) {
      int n;
      cin>>n;
      ll s = 0;
      ll fo = 0, th = 0;
      for (int i = 0; i < n; i++) {
	ll x;
	cin>>x;
	s += x;
	if (x % 5 < 3) s -= x % 5;
	else if (x % 5 == 3) th++;
	else fo++;
      }
      while (fo && th) {
	s -= 2;
	fo--;
	th--;
      }
      while (th >= 2) th -= 2, s -= 1;
      if (th) s += 2;
      while (fo >= 3) fo -= 3, s -= 2;
      if (fo) s += fo;
      cout<<s<<endl;
  }
}

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
...

Test 2

Verdict: ACCEPTED

input
1
100000
666086355 190481330 514353517 ...

correct output
47176864928795

user output
47176864928795