QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#114272 | #5977. Smoothing Window | zwh2008 | 0 | 5ms | 3848kb | C++14 | 715b | 2023-06-21 20:54:31 | 2023-06-21 20:54:34 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1005,M=105;
int n,k,Case,s[N],mx[M],l[M],b[N];
int F(int x,int k){if(x<=0)return 0;return (x-1)/k+1;}
void solve() {
scanf("%d%d",&n,&k);
for(int i=1;i<=n-k+1;i++)scanf("%d",s+i);
for(int i=0;i<=k;i++)mx[i]=l[i]=b[i]=0;
int now=0,sl=0,Mx=0,d=0;
for(int i=k+1;i<=n;i++)now-=b[i-k],b[i]=s[i-k+1]-s[1]-now,now+=b[i];
for(int i=1;i<=n;i++)mx[i%k]=max(mx[i%k],b[i]),l[i%k]=max(l[i%k],-b[i]);
for(int i=0;i<k;i++)sl+=l[i],Mx=max(Mx,l[i]+mx[i]);
for(int i=0;i<k;i++)d+=Mx-mx[i];
printf("Case #%d: %d\n",++Case,Mx+F(((s[1]-sl)%k+k)%k-d,k));
}
int main() {
int tt;scanf("%d",&tt);
while(tt--)solve();
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: 2ms
memory: 3812kb
input:
100 10 2 1 2 3 4 5 6 7 8 9 100 100 -100 7 3 0 12 0 12 0 100 50 0 62 0 62 124 186 124 186 124 62 124 62 0 62 0 -62 0 62 124 186 248 310 248 310 372 310 248 186 124 62 124 62 0 -62 0 -62 -124 -152 -214 -276 -214 -276 -214 -276 -338 -276 -338 -276 -214 -276 -214 100 2 -3228 -470 -1454 -4039 -3924 -4107...
output:
Case #1: 5 Case #2: 0 Case #3: 12 Case #4: 62 Case #5: 3207 Case #6: 171 Case #7: 239 Case #8: 230 Case #9: 383 Case #10: 320 Case #11: 146 Case #12: 345 Case #13: 97 Case #14: 236 Case #15: 347 Case #16: 29 Case #17: 325 Case #18: 62 Case #19: 327 Case #20: 257 Case #21: 193 Case #22: 348 Case #23:...
result:
wrong answer 5th lines differ - expected: 'Case #5: 3208', found: 'Case #5: 3207'
Subtask #2:
score: 0
Wrong Answer
Test #2:
score: 0
Wrong Answer
time: 5ms
memory: 3848kb
input:
100 10 2 1 2 3 4 5 6 7 8 9 100 100 -100 7 3 0 12 0 12 0 100 50 0 62 0 62 124 186 124 186 124 62 124 62 0 62 0 -62 0 62 124 186 248 310 248 310 372 310 248 186 124 62 124 62 0 -62 0 -62 -124 -152 -214 -276 -214 -276 -214 -276 -338 -276 -338 -276 -214 -276 -214 100 2 -3228 -470 -1454 -4039 -3924 -4107...
output:
Case #1: 5 Case #2: 0 Case #3: 12 Case #4: 62 Case #5: 3207 Case #6: 171 Case #7: 239 Case #8: 385 Case #9: 301 Case #10: 293 Case #11: 161 Case #12: 73 Case #13: 134 Case #14: 372 Case #15: 304 Case #16: 9 Case #17: 9 Case #18: 102 Case #19: 47 Case #20: 109 Case #21: 143 Case #22: 52 Case #23: 49 ...
result:
wrong answer 5th lines differ - expected: 'Case #5: 3208', found: 'Case #5: 3207'