QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#838436#9920. Money Game 2kkkgjyismine4WA 4ms5676kbC++201.1kb2024-12-31 11:16:312024-12-31 11:16:31

Judging History

This is the latest submission verdict.

  • [2024-12-31 22:17:02]
  • hack成功,自动添加数据
  • (/hack/1322)
  • [2024-12-31 21:57:13]
  • hack成功,自动添加数据
  • (/hack/1321)
  • [2024-12-31 11:16:31]
  • Judged
  • Verdict: WA
  • Time: 4ms
  • Memory: 5676kb
  • [2024-12-31 11:16:31]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
#define N 2000005
#define ll long long
#define pii pair<ll,int>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
int n;ll a[N];
vector<pii>L[N],R[N];
void solve(){
	cin>>n;
	for(int i=1;i<=n;++i)cin>>a[i];
	for(int i=n+1;i<=2*n;++i)a[i]=a[i-n];
	n*=2,R[n+1].clear();
	for(int i=1;i<=n;++i)L[i].clear(),R[i].clear();
	for(int i=1;i<=n;++i){
		L[i].pb(mp(a[i],i));ll lst=a[i];
		for(auto v:L[i-1]){
			if((v.fi/2ll+a[i])==lst)continue;
			lst=v.fi/2ll+a[i],L[i].pb(mp(v.fi/2ll+a[i],v.se));
		}
	}
	for(int i=n;i;--i){
		R[i].pb(mp(a[i],i));ll lst=a[i];
		for(auto v:R[i+1]){
			if((v.fi/2ll+a[i])==lst)continue;
			lst=v.fi/2ll+a[i],R[i].pb(mp(v.fi/2ll+a[i],v.se));
		}
	}
	for(int i=n/2+1;i<=n;++i){
		ll mx=0;
		int n1=(int)(R[i-n/2].size())-1;
		for(auto v:L[i]){
			while(n1>=0&&R[i-n/2][n1].se>=v.se)--n1;
			if(n1>=0)mx=max(mx,v.fi+R[i-n/2][n1].se-a[i]);
		}
		cout<<mx<<" ";
	}cout<<endl;
}
int main(){
	ios::sync_with_stdio(0);
	int T;cin>>T;
	while(T--)solve();
	return 0;
} 

详细

Test #1:

score: 0
Wrong Answer
time: 4ms
memory: 5676kb

input:

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

output:

6 6 6 8 8 
4 6 6 7 7 
1 

result:

wrong answer 2nd numbers differ - expected: '5', found: '6'