QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#193416 | #7522. Sequence Shift | ucup-team896# | WA | 1ms | 9824kb | C++14 | 1.0kb | 2023-09-30 17:06:56 | 2023-09-30 17:06:56 |
Judging History
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*600/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: 0ms
memory: 9820kb
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: 9812kb
input:
1 0 103509429 823330096
output:
926839525
result:
ok single line: '926839525'
Test #3:
score: -100
Wrong Answer
time: 1ms
memory: 9824kb
input:
1 1 576560149 691846236 1156187222
output:
1268406385 1268406385
result:
wrong answer 2nd lines differ - expected: '835582012', found: '1268406385'