QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#236608 | #7522. Sequence Shift | MLE | WA | 1ms | 10032kb | C++14 | 996b | 2023-11-04 09:00:58 | 2023-11-04 09:00:59 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
using namespace std;
inline int read(){
int x=0,f=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;
}
const int N=1e6+10;
const int M=1e9;
int n,k,q,lst,maxn,a[N],b[N],c[N<<1],d[N<<1],L=1,R=0;
mt19937 rnd(time(0));
signed main()
{
n=read(),q=read();
for(int i=1;i<=n;i++)a[i]=read(),maxn=max(maxn,a[i]);
for(int i=1;i<=n;i++)b[i]=read();
for(int i=1;i<=n;i++)lst=max(lst,a[i]+b[i]);
printf("%lld",lst);
putchar('\n');
k=max(lst-maxn-N,0ll);
for(int i=1;i<=n;i++)
if(b[i]>=k){
R++;
c[R]=b[i];
d[R]=i;
}
while(q--){
int x=read()^lst;
lst=0;
for(int i=L;i<=R;i++){
d[i]--;
if(d[i])lst=max(lst,c[i]+a[d[i]]);
}
if(d[L]==0)L++;
if(x>=k){
R++;
c[R]=x;
d[R]=n;
lst=max(lst,x+a[n]);
}
k=max(lst-maxn-N,k);
printf("%lld",lst);
putchar('\n');
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 10028kb
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: 10032kb
input:
1 0 103509429 823330096
output:
926839525
result:
ok single line: '926839525'
Test #3:
score: -100
Wrong Answer
time: 1ms
memory: 10004kb
input:
1 1 576560149 691846236 1156187222
output:
1268406385 0
result:
wrong answer 2nd lines differ - expected: '835582012', found: '0'