QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#193429#7522. Sequence Shiftucup-team896#WA 1ms9864kbC++141.0kb2023-09-30 17:08:392023-09-30 17:08:41

Judging History

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

  • [2023-09-30 17:08:41]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:9864kb
  • [2023-09-30 17:08:39]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=1e6+7;
int n,q,a[N],b[N*2],c[N],d[N*2];
int ans[N],lim;
vector<int>e;
int maxn[210];
void del(int id){
	for(int i=1;i<=100;i++)
		if(maxn[i]==id){
			for(int j=i;j<100;j++)
				maxn[i]=maxn[i+1];
		}
	return; 
}void add(int vl,int id){
	for(int i=1;i<=100;i++)
		if(vl>b[maxn[i]]||maxn[i]==0){
			maxn[i]=id;
			return;
		}
	return;
}
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);cin>>n>>q;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		c[i]=a[i];
	}sort(c+1,c+n+1);
	lim=c[max(1,n-N*620/n)];
	for(int i=1;i<=n;i++)
		cin>>b[i];
	for(int i=1;i<=n;i++)
		if(a[i]>=lim)e.push_back(i);
	int ans=0;
	for(int i=1;i<=n;i++){
		ans=max(ans,a[i]+b[i]);
		add(b[i],i);
	}
	cout<<ans<<"\n";
	for(int i=1;i<=q;i++){
		del(i);
		cin>>b[n+i];
		b[n+i]^=ans;
		add(b[n+i],n+i);
		for(auto v:e)ans=max(ans,a[v]+b[v+i]);
		for(int j=1;j<=100;j++)if(maxn[j]>=i+1&&maxn[j]<=i+n)
			ans=max(ans,b[maxn[j]]+a[maxn[j]-i]);
		cout<<ans<<"\n";
	}return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 9728kb

input:

5 3
1 4 3 2 5
7 5 8 3 2
3
6
4

output:

11
13
16
25

result:

ok 4 lines

Test #2:

score: 0
Accepted
time: 1ms
memory: 9768kb

input:

1 0
103509429
823330096

output:

926839525

result:

ok single line: '926839525'

Test #3:

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

input:

1 1
576560149
691846236
1156187222

output:

1268406385
1268406385

result:

wrong answer 2nd lines differ - expected: '835582012', found: '1268406385'