QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#209761 | #7522. Sequence Shift | c20230201 | WA | 52ms | 10416kb | C++14 | 875b | 2023-10-10 17:07:23 | 2023-10-10 17:07:24 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll maxn=2e6+5;
ll a2[maxn], b[maxn], ans[maxn];
struct node {
ll id;
ll v;
}a[maxn];
bool cmp(node x,node y) {
return x.v>y.v;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
ll n,q; cin>>n>>q;
for(ll i=1;i<=n;i++) cin>>a[i].v, a[i].id=i, a2[i]=a[i].v;
sort(a+1,a+n+1,cmp);
ll mn=10*(1e9/sqrt(n));
for(ll i=1;i<=n+q;i++) {
cin>>b[i];
if(i>n) {
if(ans[i-n]==0) {
for(ll j=i-n;j<i;j++) ans[i-n]=max(ans[i-n],a2[j-(i-n)+1]+b[j]);
}
b[i]^=ans[i-n];
}
for(ll j=1;j<=n;j++) {
if(a[j].v<mn) break;
if(a[j].id<=j) ans[i-j+1]=max(ans[i-a[j].id+1],b[i]+a[j].v);
}
}
if(ans[q+1]==0) {
for(ll i=1;i<=n;i++) ans[q+1]=max(ans[q+1],a2[i]+b[i+q]);
}
for(ll i=1;i<=q+1;i++) cout<<ans[i]<<'\n';
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 7532kb
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: 7504kb
input:
1 0 103509429 823330096
output:
926839525
result:
ok single line: '926839525'
Test #3:
score: 0
Accepted
time: 1ms
memory: 7596kb
input:
1 1 576560149 691846236 1156187222
output:
1268406385 835582012
result:
ok 2 lines
Test #4:
score: 0
Accepted
time: 0ms
memory: 7536kb
input:
1 10 700282491 332230980 90825676 1630266999 644973380 262379760 2122877054 1851957134 1370195232 110993724 1319359505 1883523208
output:
1032513471 1654684398 759763732 888538827 1695749302 1163465539 1425605448 789576931 1397740634 1202288326 1638577353
result:
ok 11 lines
Test #5:
score: -100
Wrong Answer
time: 52ms
memory: 10416kb
input:
1000 100000 438001359 929744877 710148392 323984311 727016267 323629255 495752276 309120511 312675195 717795522 937464489 624952229 444774478 829169766 707441777 609125148 25459976 849166512 716162953 882416779 189669312 135698832 632796131 592794700 569746403 231058028 389412868 824283503 801480367...
output:
1484552281 816127786 1128008387 836262657 1137219040 1086789551 1244199404 1556080005 1354633691 1482846463 1555488894 1037786536 690211144 967166415 1018251655 1040100254 1351980855 1115075227 1219745356 1230793141 1542673742 1592312465 1320252715 1394050613 1054410363 1366290964 899696344 11137128...
result:
wrong answer 1st lines differ - expected: '1962871590', found: '1484552281'