QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#207881#7522. Sequence ShiftczcRE 0ms5792kbC++141.1kb2023-10-08 21:58:512023-10-08 21:58:51

Judging History

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

  • [2023-10-08 21:58:51]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:5792kb
  • [2023-10-08 21:58:51]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int n,q; 
const int T=1e6;
const int maxn=1e6+5;
vector< pair<int,int> > v1,v2;
int a[maxn],b[maxn<<1];
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cin>>n>>q; 
	for(int i=1;i<=n;i++){
		cin>>a[i];
		if(a[i]>T) v1.push_back(make_pair(i,a[i]));
	}
	for(int i=1;i<=n;i++){
		cin>>b[i];
		if(b[i]>T) v2.push_back(make_pair(i,b[i]));
	}
	int lastans=0;
	for(int i=1;i<=n;i++){
		lastans=max(lastans,a[i]+b[i]);
	}
	cout<<lastans<<endl; 
	for(int i=1;i<=q;i++){
		cin>>b[i+n];
		b[i+n]^=lastans;
		for(auto it=v2.begin();it!=v2.end();it++){
			if((*it).first==1){
				it=v2.erase(it);
				continue;
			}
			(*it).first--;
		}
		if(b[i+n]>T) v2.push_back(make_pair(n,b[i+n]));
		bool f=0;
		int ans=0;
		for(int k=0,j=0;k<(int)v1.size();k++){
			while(j<(int)v2.size() && v2[j].first<v1[j].first){
				j++;
			}
			if(j<(int)v2.size() && v2[j].first==v1[k].first){
				ans=max(ans,v2[j].second+v1[k].second);
				f=1;
			}
		}
		if(!f){
			for(int j=1;j<=n;j++){
				ans=max(ans,a[j]+b[i+j]);
			}
		}
		cout<<(lastans=ans)<<endl;
	}
	return 0;
}

详细

Test #1:

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

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: 0ms
memory: 5792kb

input:

1 0
103509429
823330096

output:

926839525

result:

ok single line: '926839525'

Test #3:

score: -100
Runtime Error

input:

1 1
576560149
691846236
1156187222

output:

1268406385

result: