QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#114273#5977. Smoothing Windowzwh200813 ✓7ms3864kbC++14720b2023-06-21 20:59:422023-06-21 20:59:43

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-06-21 20:59:43]
  • 评测
  • 测评结果:13
  • 用时:7ms
  • 内存:3864kb
  • [2023-06-21 20:59:42]
  • 提交

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]-l[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;
}

详细

Subtask #1:

score: 6
Accepted

Test #1:

score: 6
Accepted
time: 2ms
memory: 3864kb

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: 3208
Case #6: 172
Case #7: 239
Case #8: 230
Case #9: 383
Case #10: 320
Case #11: 147
Case #12: 345
Case #13: 97
Case #14: 236
Case #15: 347
Case #16: 29
Case #17: 326
Case #18: 63
Case #19: 328
Case #20: 258
Case #21: 193
Case #22: 348
Case #23:...

result:

ok 100 lines

Subtask #2:

score: 7
Accepted

Test #2:

score: 7
Accepted
time: 7ms
memory: 3624kb

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: 3208
Case #6: 172
Case #7: 240
Case #8: 386
Case #9: 302
Case #10: 294
Case #11: 162
Case #12: 74
Case #13: 135
Case #14: 372
Case #15: 304
Case #16: 10
Case #17: 10
Case #18: 103
Case #19: 48
Case #20: 110
Case #21: 143
Case #22: 52
Case #23: 4...

result:

ok 100 lines

Extra Test:

score: 0
Extra Test Passed