QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#209763#7522. Sequence Shiftc20230201WA 71ms10644kbC++14891b2023-10-10 17:10:142023-10-10 17:10:14

Judging History

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

  • [2023-10-10 17:10:14]
  • 评测
  • 测评结果:WA
  • 用时:71ms
  • 内存:10644kb
  • [2023-10-10 17:10:14]
  • 提交

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 w=1e9;
	ll mn=w-w/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+b[i]<w*2-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: 1ms
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: 7768kb

input:

1 0
103509429
823330096

output:

926839525

result:

ok single line: '926839525'

Test #3:

score: 0
Accepted
time: 1ms
memory: 7828kb

input:

1 1
576560149
691846236
1156187222

output:

1268406385
835582012

result:

ok 2 lines

Test #4:

score: 0
Accepted
time: 0ms
memory: 7776kb

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: 71ms
memory: 10644kb

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:

1713836385
1888348547
1616091286
1778474703
1505532016
1797244673
1722041023
1855096882
1738281491
1421809728
1810698188
1597540358
1618872187
1789761912
1799710866
1819707534
1625775419
1799710866
1983723025
1061304735
1149439031
1613674948
1799710866
1666023934
1719406866
1466509232
1101553250
147...

result:

wrong answer 1st lines differ - expected: '1962871590', found: '1713836385'