| Task: | Cent saving |
| Sender: | asdf |
| Submission time: | 2024-09-28 12:37:46 +0300 |
| Language: | C++ (C++20) |
| Status: | READY |
| Result: | WRONG ANSWER |
| test | verdict | time | |
|---|---|---|---|
| #1 | WRONG ANSWER | 0.02 s | details |
| #2 | WRONG ANSWER | 0.02 s | details |
Code
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1e5 + 5;
int n, p[N];
int cnt[10];
void solve() {
cin >> n;
memset(cnt, 0, sizeof cnt);
int sum = 0;
for (int i = 1; i <= n; i++) {
cin >> p[i];
sum += p[i];
p[i] %= 10;
cnt[p[i]]++;
}
int ans = 0;
// connect 4 & 9 first
// take 4 from 3
{
int take = min(cnt[4], cnt[3]);
cnt[4] -= take;
cnt[3] -= take;
ans += take * 2;
}
// take 4 from 8
{
int take = min(cnt[4], cnt[8]);
cnt[4] -= take;
cnt[8] -= take;
ans += take * 2;
}
// take 9 from 3
{
int take = min(cnt[9], cnt[3]);
cnt[9] -= take;
cnt[3] -= take;
ans += take * 2;
}
// take 9 from 8
{
int take = min(cnt[9], cnt[8]);
cnt[9] -= take;
cnt[8] -= take;
ans += take * 2;
}
// take 3 with 8
{
int take = min(cnt[3], cnt[8]);
cnt[3] -= take;
cnt[8] -= take;
ans += take * 2;
}
// take 3 & 3
{
int take = cnt[3] / 2;
ans += take;
}
// take 3 & 3
{
int take = cnt[8] / 2;
ans += take;
}
cout << sum - ans << '\n';
}
signed main() {
cin.tie(0)->sync_with_stdio(0);
int t;
cin >> t;
while (t--) {
solve();
}
}Test details
Test 1
Verdict: WRONG ANSWER
| input |
|---|
| 100 1000 528433894 255789530 559301042 ... |
| correct output |
|---|
| 475191144965 460688647850 478543444030 475238936090 456736521510 ... |
| user output |
|---|
| 475191145600 460688648504 478543444596 475238936708 456736522133 ... Truncated |
Test 2
Verdict: WRONG ANSWER
| input |
|---|
| 1 100000 666086355 190481330 514353517 ... |
| correct output |
|---|
| 47176864928795 |
| user output |
|---|
| 47176864988470 |
