QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#209762 | #7522. Sequence Shift | c20230201 | WA | 78ms | 10664kb | C++14 | 872b | 2023-10-10 17:08:10 | 2023-10-10 17:08:11 |
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=(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: 7836kb
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: 7780kb
input:
1 0 103509429 823330096
output:
926839525
result:
ok single line: '926839525'
Test #3:
score: 0
Accepted
time: 1ms
memory: 7796kb
input:
1 1 576560149 691846236 1156187222
output:
1268406385 835582012
result:
ok 2 lines
Test #4:
score: 0
Accepted
time: 1ms
memory: 7788kb
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: 78ms
memory: 10664kb
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:
1646310094 1332372424 1800061252 1690332212 1675074951 1712510693 1652716444 1577390687 1506189723 1799918011 1740123762 1653968069 1104193801 1627516815 1582753872 1741375387 1380114420 1699934713 1646200658 1248025153 1644082855 1787342031 1724825814 1269398434 1731490173 1819366861 1642364468 135...
result:
wrong answer 1st lines differ - expected: '1962871590', found: '1646310094'