QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#407356 | #8225. 最小值之和 | starry-sky-155 | 0 | 0ms | 1580kb | C++14 | 1.3kb | 2024-05-08 16:28:42 | 2024-05-08 16:28:44 |
answer
#include <cstdio>
#include <cstring>
#include <algorithm>
#define int long long
using namespace std;
int T, n, a, b, _sum, cnt[10], tmp;
signed main() {
scanf("%lld", &T);
while (T --) {
scanf("%lld", &n);
_sum = 0;
memset(cnt, 0, sizeof(cnt));
for (int i = 1; i <= n; i ++) {
scanf("%lld.%lld", &a, &b);
_sum += a;
if (b >= 5) {
_sum ++;
} else {
cnt[b] ++;
}
}
tmp = min(cnt[4], cnt[1]);
_sum += tmp;
cnt[4] -= tmp;
cnt[1] -= tmp;
tmp = min(cnt[3], cnt[2]);
_sum += tmp;
cnt[3] -= tmp;
cnt[2] -= tmp;
tmp = min(cnt[3], cnt[1] / 2);
_sum += tmp;
cnt[3] -= tmp;
cnt[1] -= tmp * 2;
tmp = min(cnt[2] / 2, cnt[1]);
_sum += tmp;
cnt[2] -= tmp * 2;
cnt[1] -= tmp;
tmp = min(cnt[2], cnt[1] / 3);
_sum += tmp;
cnt[2] -= tmp;
cnt[1] -= tmp * 3;
_sum += cnt[1] / 5;
cnt[1] %= 5;
tmp = min(cnt[4], cnt[2]);
_sum += tmp;
cnt[4] -= tmp;
cnt[1] -= tmp;
_sum += cnt[3] / 2;
cnt[3] %= 2;
_sum += cnt[2] / 3;
cnt[2] %= 3;
tmp = min(cnt[4], cnt[3]);
_sum += tmp;
cnt[4] -= tmp;
cnt[3] -= tmp;
_sum += cnt[4] / 2;
cnt[4] %= 2;
tmp = 0;
for (int i = 1; i <= 4; i ++) {
tmp += cnt[i] * i;
}
_sum += tmp / 10;
printf("%lld\n", _sum);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 1580kb
input:
5 14 14 12 13 13
output:
182 182 182 182 182
result:
wrong answer Line 1 expected
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Skipped
Dependency #2:
0%
Subtask #4:
score: 0
Skipped
Dependency #1:
0%
Subtask #5:
score: 0
Skipped
Dependency #1:
0%
Subtask #6:
score: 0
Skipped
Dependency #1:
0%