QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#857425#9920. Money Game 2asdf__WA 0ms9960kbC++141.3kb2025-01-15 17:45:432025-01-15 17:45:52

Judging History

This is the latest submission verdict.

  • [2025-01-15 17:45:52]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 9960kb
  • [2025-01-15 17:45:43]
  • Submitted

answer

#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
const int N=5e5+5;
int ans[2][N][35][2],n,a[N],T,cnt[2][N],v;
void cl(int i,int j,int v){
	ans[v][i][1][0]=1;
	ans[v][i][1][1]=a[i];
	cnt[v][i]=1; 
	for(int k=1;k<=cnt[v][j];k++){
		if(ans[v][j][k][1]/2+a[i]!=ans[v][i][cnt[v][i]][1]){
			cnt[v][i]++;
			ans[v][i][cnt[v][i]][0]=ans[v][j][k][0]+1;
			ans[v][i][cnt[v][i]][1]=ans[v][j][k][1]/2+a[i];
		}
	}
}
void cl(int v){
	cl(1,n,v);
	for(int i=2;i<=n;i++) cl(i,i-1,v);
}
int main(){
//	freopen("1.in","r",stdin);
	scanf("%d",&T);
	while(T--){
		scanf("%d",&n);
		for(int i=1;i<=n;i++) scanf("%d",&a[i]),cnt[0][i]=cnt[1][i]=0;
		if(n==1){
			printf("%d\n",a[1]);
			continue;
		}
		if(n==2){
			printf("%d %d\n",a[1]+a[2]/2,a[2]+a[1]/2);
			continue;
		}
		cl(0);
		cl(0);
		v=(n+1)/2;
		for(int i=1;i<=n/2;i++) swap(a[i],a[n-i+1]);
		cl(1);
		cl(1);
		for(int i=1;i<=n;i++){
			int an=0,j=1;
			while(ans[0][i][j][0]<=n+1 && j<cnt[0][i]) j++;
			an=ans[0][i][j][1];
			for(int k=1;k<=cnt[1][n-i+1];k++){
				while(ans[0][i][j][0]+ans[1][n-i+1][k][0]>n+1 && j) j--;
				if(!j) an=max(an,ans[1][n-i+1][k][1]);
				else an=max(an,ans[0][i][j][1]+ans[1][n-i+1][k][1]-a[n-i+1]);
			}
			printf("%d ",an);
		}
		printf("\n");
	}
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 7908kb

input:

3
5
2 1 4 3 5
5
2 1 3 1 2
1
1000000000

output:

6 5 7 8 8 
4 4 5 4 4 
1000000000

result:

ok 11 numbers

Test #2:

score: 0
Accepted
time: 0ms
memory: 9960kb

input:

1
10
8 15 18 15 13 4 14 4 17 5

output:

30 37 41 39 34 27 29 26 31 27 

result:

ok 10 numbers

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 9960kb

input:

1000
4
8 9 7 9
1
9
1
10
2
3 9
3
4 3 2
4
0 4 3 1
4
10 8 4 6
1
9
1
4
4
10 10 1 6
1
9
1
0
2
4 6
4
8 1 6 7
2
5 10
4
9 2 1 4
3
5 5 9
3
9 8 9
4
4 8 5 6
2
10 1
1
7
3
9 2 4
4
2 4 1 2
3
5 2 1
1
4
3
2 0 9
4
7 3 10 1
3
4 1 2
2
6 4
1
2
3
3 1 5
3
5 8 4
2
9 3
4
5 9 10 3
4
6 5 4 0
1
6
4
3 1 10 1
4
1 9 5 7
4
8 1 6 ...

output:

18 18 17 18 
9
10
7 10
6 6 5 
3 6 5 3 
18 16 13 15 
9
4
18 17 11 14 
9
0
7 8
13 9 12 14 
10 12
12 8 6 9 
11 11 14 
17 16 17 
12 14 13 12 
10 6
7
12 8 9 
5 6 4 4 
7 5 4 
4
6 5 11 
11 11 14 10 
5 4 4 
8 7
2
6 4 7 
11 12 10 
10 7
13 17 17 12 
10 10 8 6 
6
6 7 12 7 
9 14 12 12 
14 10 13 16 
18 15 18 19 ...

result:

wrong answer 13th numbers differ - expected: '5', found: '6'