QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#859435 | #9679. 盒子 | lgvc | 0 | 52ms | 5964kb | C++23 | 1.2kb | 2025-01-17 19:02:45 | 2025-01-17 19:02:47 |
Judging History
answer
#include <bits/stdc++.h>
#define LL long long
int T,N,M,K,C,a[1000009];
LL dp[1000009];
signed main(void) {
scanf("%d",&T);
while(T--) {
scanf("%d %d %d %d",&N,&M,&K,&C);
LL ans=0;
for(int i=1;i<=N;i++) {
scanf("%d",&a[i]);
ans+=a[i];
}
int p=1;
while(1) {
while(p<=N&&(a[p]==0)) p++;
if(p>N) break;
ans-=(a[p]/K)*(K-C);
a[p]%=K;
LL su=0;
for(int i=p;i<p+M&&i<=N;i++) {
su+=a[i];
}
if(su<K) {
p++;
} else {
int le=K;
for(int i=p;i<p+M&&i<=N;i++) {
LL tq=std::min(a[i],le);
le-=tq;a[i]-=tq;
}
ans-=(K-le)-C;
}
}
for(int i=1;i<=N;i++) {
dp[i]=dp[i-1];
LL ss=0;
for(int j=i;j>=i-M+1&&j>=1;j--) {
ss+=a[j];
}
if(ss>C) dp[i]=std::max(dp[i],dp[std::max(i-M,0)]+ss-C);
}
printf("%lld\n",ans-dp[N]);
}
}
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 17
Accepted
time: 0ms
memory: 5964kb
input:
3 5 2 4 3 2 2 1 2 2 4 2 4 3 2 4 1 1 10 3 5 1 2 2 2 2 1 1 1 10 2 2
output:
7 7 6
result:
ok 3 number(s): "7 7 6"
Test #2:
score: 0
Wrong Answer
time: 0ms
memory: 5964kb
input:
65 7 1 27 22 70 29 32 15 69 79 84 10 2 2 1 76 63 99 67 75 30 29 45 79 23 9 1 4 3 47 91 10 30 91 29 12 14 53 10 1 5 4 92 22 92 27 30 50 59 6 57 58 5 2 15 15 59 27 70 24 11 5 2 42 42 70 50 42 55 5 6 2 54 46 67 14 52 80 95 3 10 2 89 88 55 14 45 14 90 81 38 40 54 17 5 2 93 86 35 58 76 64 73 6 1 45 43 63...
output:
320 293 287 398 191 222 271 445 285 344 307 270 348 312 370 427 199 185 318 502 344 197 330 233 262 220 454 243 160 280 482 580 330 373 202 293 228 590 268 475 253 494 523 476 186 223 368 323 368 392 507 494 132 209 224 250 297 216 525 558 172 448 433 430 578
result:
wrong answer 18th numbers differ - expected: '184', found: '185'
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Skipped
Dependency #2:
0%
Subtask #4:
score: 0
Wrong Answer
Test #35:
score: 0
Wrong Answer
time: 52ms
memory: 5964kb
input:
66664 7 2 82188055 1 35930054 4923258 36288509 46890418 53350617 49812938 68015568 10 2 460335201 1 305598063 240803174 36008172 416771728 391050572 270293987 333994588 436573185 216917970 103343453 9 3 119910901 1 35106715 29444257 72409421 49339248 23617992 3266647 38704192 75874356 72979434 10 1 ...
output:
6 8 5 13 8 4 8 13 4 4 6 10 8 6 11 13 9 14 5 8 5 11 11 6 4 9 7 4 6 6 7 5 5 12 6 9 3 5 10 12 7 6 14 15 5 7 14 14 8 5 8 7 9 8 4 10 8 8 8 7 7 6 11 7 7 5 7 7 5 9 9 9 7 5 4 5 7 6 7 13 7 10 12 6 4 10 14 7 3 7 5 4 7 9 8 13 5 5 8 10 6 6 6 15 10 15 11 4 4 6 7 6 11 13 6 16 13 8 8 10 7 14 11 7 7 9 10 10 8 5 6 7...
result:
wrong answer 1st numbers differ - expected: '5', found: '6'
Subtask #5:
score: 0
Skipped
Dependency #1:
0%