QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#720862 | #8281. Pangu and Stones | Mine_King | WA | 1ms | 3904kb | C++14 | 1.3kb | 2024-11-07 14:30:45 | 2024-11-07 14:30:45 |
Judging History
answer
// 長い夜の終わりを信じながら
// Think twice, code once.
#include <queue>
#include <vector>
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>
#define eputchar(c) putc(c, stderr)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define eputs(str) fputs(str, stderr), putc('\n', stderr)
using namespace std;
int n, l, r, a[105];
priority_queue<int, vector<int>, greater<>> q;
long long ans = 0x3f3f3f3f3f3f3f3f;
int main() {
scanf("%d%d%d", &n, &l, &r);
for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
for (int i = 1; i <= n - 1; i++) {
int num = (n - 1) / i, cnt = (n - 1) % i;
while (!q.empty()) q.pop();
for (int j = 1; j <= n; j++) q.emplace(a[j]);
int flag = 1;
long long res = 0;
for (int j = 1; j <= cnt; j++) {
flag &= l <= num + 2 && num + 2 <= r;
int sum = 0;
for (int k = 1; k <= num + 2; k++) sum += q.top(), q.pop();
res += sum;
q.push(sum);
}
for (int j = 1; j <= i - cnt; j++) {
flag &= l <= num + 1 && num + 1 <= r;
int sum = 0;
for (int k = 1; k <= num + 1; k++) sum += q.top(), q.pop();
res += sum;
q.push(sum);
}
if (flag) ans = min(ans, res);
}
printf("%lld\n", ans != 0x3f3f3f3f3f3f3f3f ? ans : 0ll);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3828kb
input:
3 2 2 1 2 3
output:
9
result:
ok 1 number(s): "9"
Test #2:
score: 0
Accepted
time: 1ms
memory: 3904kb
input:
3 2 3 1 2 3
output:
6
result:
ok 1 number(s): "6"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3844kb
input:
4 3 3 1 2 3 4
output:
0
result:
ok 1 number(s): "0"
Test #4:
score: -100
Wrong Answer
time: 1ms
memory: 3820kb
input:
100 4 7 570 608 194 26 243 470 418 119 1000 936 440 302 797 155 676 283 869 60 959 793 158 397 808 656 379 316 485 854 753 280 543 435 756 822 106 561 402 347 99 739 8 682 834 549 812 32 338 765 699 575 575 785 171 504 335 113 284 612 276 518 835 677 865 900 687 48 859 179 343 318 626 812 523 11 400...
output:
123011
result:
wrong answer 1st numbers differ - expected: '120446', found: '123011'