QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#192030#7522. Sequence Shiftucup-team266#WA 521ms34284kbC++141.9kb2023-09-30 13:21:182023-09-30 13:21:18

Judging History

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

  • [2023-09-30 13:21:18]
  • 评测
  • 测评结果:WA
  • 用时:521ms
  • 内存:34284kb
  • [2023-09-30 13:21:18]
  • 提交

answer

/*
Things to notice:
1. do not calculate useless values
2. do not use similar names
 
Things to check:
1. submit the correct file
2. time (it is log^2 or log)
3. memory
4. prove your naive thoughts 
5. long long
6. corner case like n=0,1,inf or n=m
7. check if there is a mistake in the ds or other tools you use
8. fileio in some oi-contest

9. module on time 
10. the number of a same divisor in a math problem
11. multi-information and queries for dp and ds problems
*/
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
const int mod=998244353;
const int inf=0x3f3f3f3f;
const int B=4000;
int q,a[2000005],b[2000005],n,m,ans[2000005],lst;
pii c[2000005];
void solve()
{
	cin>>n>>q;
	m=n;
	for(int i=1;i<=n;i++) cin>>a[i],c[i]=mp(a[i],i);
	sort(c+1,c+1+n);
	
	for(int i=1;i<=n;i++) cin>>b[i],ans[0]=max(ans[0],a[i]+b[i]);
	priority_queue <int,vector<int>, greater<int> > qa,qb;
	for(int i=1;i<=n;i++) 
	{
		qa.push(a[i]),qb.push(a[i]);
		if(qa.size()>B) qa.pop();
		if(qb.size()>B) qb.pop();
	}
	for(int i=1;i<=n;i++)
	{
		int lim=qa.top()+qb.top()-b[i];
		int p=lower_bound(c+1,c+1+n,mp(lim,0))-c;
		for(int j=p;j<=n;j++)
		{
			int v=c[j].se;
			if(v<i) ans[i-v]=max(ans[i-v],a[v]+b[i]);
		}
	}
	lst=ans[0];
	cout<<lst<<"\n";
	for(int i=1;i<=q;i++)
	{
		int v;
		cin>>v;
		v^=lst;
		b[++m]=v;
		qb.push(v);
		if(qb.size()>B) qb.pop();
		int lim=qa.top()+qb.top()-b[m];
		int p=lower_bound(c+1,c+1+n,mp(lim,0))-c;
		for(int j=p;j<=n;j++)
		{
			v=c[j].se;
			if(v<m) ans[m-v]=max(ans[m-v],a[v]+b[m]);
		}
		lst=ans[i];
		cout<<lst<<"\n";
	}
}
signed main()
{
//	freopen("K.in","r",stdin);
//	freopen("K.out","w",stdout);
	ios::sync_with_stdio(0);
	cin.tie(0);
	int _=1;
//	cin>>_;
	while(_--) solve();
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 7692kb

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: 7720kb

input:

1 0
103509429
823330096

output:

926839525

result:

ok single line: '926839525'

Test #3:

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

input:

1 1
576560149
691846236
1156187222

output:

1268406385
835582012

result:

ok 2 lines

Test #4:

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

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: 0
Accepted
time: 64ms
memory: 8168kb

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:

1962871590
1986083253
1967509108
1973351244
1974354421
1956371849
1976394149
1995721753
1946870160
1984280254
1961237540
1955903880
1944520591
1937726835
1993563403
1927000559
1951483558
1979133252
1979156812
1941301401
1922284543
1980597785
1963663583
1946961524
1933606347
1953947075
1953071855
194...

result:

ok 100001 lines

Test #6:

score: 0
Accepted
time: 46ms
memory: 8172kb

input:

10000 10000
760845880 236665988 765352292 817854026 789863420 399953246 270535243 932350041 48814223 670950468 456660682 416165008 999681497 666880584 56581573 134567049 403285848 144814129 973325555 23519957 518449311 738687225 345716065 2309498 477743569 555951695 911860717 920761968 569179690 349...

output:

1990514380
1974843876
1992500750
1994731468
1983411218
1986646709
1979643361
1990060423
1988174297
1983373232
1995134632
1989936349
1993187026
1988927807
1971595730
1988272839
1990590966
1981928791
1987819156
1987483957
1979800700
1986611531
1973877196
1995735988
1985734454
1987573480
1988935268
199...

result:

ok 10001 lines

Test #7:

score: 0
Accepted
time: 146ms
memory: 10312kb

input:

10000 100000
682604470 430466819 955519058 186918998 587587373 201134122 473675328 586747694 132807628 255672373 504315038 137082392 753499284 586570202 133549919 570424589 87103369 2142325 895908281 852456682 239920694 443878018 717067433 437134318 39426086 82137124 698018668 518394430 430778732 56...

output:

1984544998
1988859370
1989789541
1976833784
1995823502
1972653611
1991119857
1993356707
1986981779
1995476314
1995610828
1993831190
1996638827
1986403811
1989382087
1993806832
1989374332
1994121941
1983565702
1985256743
1996937615
1982877527
1995705250
1986803258
1991586243
1985584711
1989505176
199...

result:

ok 100001 lines

Test #8:

score: 0
Accepted
time: 53ms
memory: 10696kb

input:

100000 1000
765888053 833515469 84953776 797547408 412620563 765574495 334638552 473705288 279331343 321129745 718689650 778307179 205668791 48820839 279108389 210915881 711034474 688831194 230042027 856832739 427928795 151766103 505848143 403162288 459045522 979683261 59438197 871004123 755234923 6...

output:

1998969019
1997756723
1990964658
1992180114
1991311226
1996318953
1999238402
1997012356
1996382741
1993901604
1990703168
1997121645
1996347278
1990978439
1993663588
1996287457
1998005763
1997236433
1994552013
1995785880
1997513392
1998761277
1994793469
1993807193
1997817922
1990146164
1997588498
199...

result:

ok 1001 lines

Test #9:

score: 0
Accepted
time: 58ms
memory: 13000kb

input:

100000 10000
155192094 32355226 10722958 680788712 355467230 837266625 393682487 504944520 573979360 618892727 168735423 928295170 158663199 129313725 187722419 800899194 169961946 297789942 3327780 993559861 568700692 901642218 989795879 846649116 947423253 851741191 365690710 469648703 903510759 7...

output:

1998324839
1998650520
1996715356
1996337565
1994069244
1994071960
1994680032
1995482692
1995353396
1996020788
1998370988
1994450866
1997311656
1992935357
1998022252
1998633241
1998507677
1997594278
1996419001
1997075873
1997413924
1995735160
1995881483
1995263027
1997718803
1998739520
1997494429
199...

result:

ok 10001 lines

Test #10:

score: 0
Accepted
time: 100ms
memory: 11272kb

input:

100000 100000
38413036 456923902 821971466 586909482 636298728 158178471 84422915 632002470 34405999 882453211 922025994 294603996 207311349 526030511 417456448 362917277 456078308 435018316 47342069 47738636 642863127 189926256 40263985 58857249 119358305 864464366 83617839 485428518 305918980 9423...

output:

1996429420
1996287202
1997245731
1997158288
1998410767
1992680343
1996866185
1991187990
1993994382
1993278697
1998519189
1996981873
1996505587
1999396980
1996368678
1994926892
1995154606
1996246700
1998278411
1995699098
1998553319
1996046134
1996078476
1994270984
1993675913
1998307200
1994292194
199...

result:

ok 100001 lines

Test #11:

score: 0
Accepted
time: 512ms
memory: 33320kb

input:

1000000 1000000
681721767 150525996 385619734 237403201 784389657 667934330 103476610 977301142 659915560 343444475 784049915 969172199 251161944 919517420 927740574 885570202 531822081 391391357 889183133 954725705 921897422 339841876 886216126 698710851 968534847 834323464 33830362 168121355 74737...

output:

1998411706
1999115826
1999454117
1998836657
1998794667
1998269776
1999755051
1999381591
1998357039
1998230113
1999809722
1999320829
1999229409
1999798765
1998535400
1998709328
1999265546
1997784237
1998664760
1999789557
1998603617
1999595456
1999705003
1998179238
1999135621
1998190124
1998561110
199...

result:

ok 1000001 lines

Test #12:

score: 0
Accepted
time: 521ms
memory: 31976kb

input:

1000000 1000000
859805191 724074841 684432991 968065382 763738910 62670003 683505489 25517834 880849716 625748657 18118867 880475047 43737843 944343853 294935089 108242311 520102508 250671619 762613856 393989946 773993874 814765461 401323635 360776723 990848704 704633672 746924583 748546216 62586244...

output:

1999153565
1998922375
1997721720
1999093273
1998838958
1999407641
1998418249
1998250909
1998448991
1998131598
1999503251
1999133323
1999668728
1996876504
1998997127
1998456693
1998474784
1998680486
1998444192
1999742746
1999261645
1997944942
1998714408
1999571606
1998009280
1998932514
1999539785
199...

result:

ok 1000001 lines

Test #13:

score: 0
Accepted
time: 514ms
memory: 33680kb

input:

1000000 1000000
37888615 592590981 983246249 993694860 743088164 607148780 708244769 663669119 101783871 203020135 692379306 642034791 686570637 118913390 516905412 890722932 508382934 550143369 931011874 538286891 771314519 434913239 771206953 582651106 718195265 574943880 460018804 34003781 649576...

output:

1999040870
1998389768
1998486987
1998750065
1999570046
1998999846
1998466959
1998597646
1998651765
1998920821
1999606259
1999460166
1998879438
1998432387
1998655595
1998499939
1999399124
1999009605
1999576501
1999096183
1998399197
1999426537
1999444674
1998133711
1998313687
1998704116
1998625599
199...

result:

ok 1000001 lines

Test #14:

score: 0
Accepted
time: 520ms
memory: 32308kb

input:

1000000 1000000
921004743 166139826 722250995 314291633 577213225 446594852 288273648 711885811 27750731 190357022 366639746 403594534 624370727 143739823 884099927 968170849 936854848 409423632 99409892 832326940 918378268 55061017 286314462 99492785 740509122 5062601 173113025 54620130 528066880 5...

output:

1998252814
1999088948
1999154632
1998556605
1998012909
1997580019
1997826212
1997205871
1999347521
1998550231
1998806656
1998616565
1997661919
1999357225
1999738820
1999207108
1998644513
1998636528
1998692736
1998182183
1999138033
1997755290
1999060027
1998904028
1998479869
1999490247
1998535527
199...

result:

ok 1000001 lines

Test #15:

score: 0
Accepted
time: 513ms
memory: 33156kb

input:

1000000 1000000
99088167 444721374 316031548 190178007 851529775 136297821 18045631 55069799 248684886 472661204 745932889 165154278 562170817 318309361 106070250 45618767 220102571 708895382 972840614 976623884 65442016 235017306 96389267 321367168 762822979 580405513 181174542 635044991 846748488 ...

output:

1999808816
1999546408
1999511887
1997972111
1999525416
1999177742
1998895382
1999301427
1998683427
1998451107
1999708795
1998116472
1998978702
1997379027
1999468104
1999286658
1996653439
1998936965
1998503852
1998407411
1999250564
1997961935
1998789825
1998485755
1997761086
1997724392
1998570689
199...

result:

ok 1000001 lines

Test #16:

score: 0
Accepted
time: 515ms
memory: 31804kb

input:

1000000 1000000
277171591 168013322 760068998 215807485 685654837 680776598 188009103 398253787 469619041 754965386 420193329 221681318 205003612 48168498 473264766 123066684 353607189 568175644 846271336 270663933 917538469 855165084 316529481 838208847 490169540 450715721 894268763 920502556 57549...

output:

1998494838
1998423114
1999462821
1998426456
1998295744
1998682373
1999287674
1998826960
1997988135
1999740840
1999768385
1998924526
1998971787
1998394666
1998840068
1998843231
1998076944
1999414593
1997932895
1999093937
1998722730
1997826457
1997776964
1999737748
1999633669
1996811057
1999941569
199...

result:

ok 1000001 lines

Test #17:

score: 0
Accepted
time: 503ms
memory: 32192kb

input:

1000000 1000000
160287719 741562167 353849551 946469666 665004090 520222671 622813790 741437775 395585901 37269569 799486473 838016869 142803702 222738035 695235089 345738793 636854912 867647394 159893546 709928174 209826409 770280158 686412798 205307423 217516101 321025929 607362985 941118905 45398...

output:

1997970576
1999041782
1998693968
1997547266
1999353061
1998266739
1998901397
1998259083
1997873026
1998269849
1998703020
1998473742
1998956498
1997667670
1998060349
1997725444
1999041853
1998424607
1998915353
1997257162
1998930679
1998683778
1999496409
1999416754
1998303929
1998215765
1997695222
199...

result:

ok 1000001 lines

Test #18:

score: 0
Accepted
time: 500ms
memory: 34284kb

input:

1000000 1000000
338371143 610078307 92854297 972099144 644353344 209925640 352585773 84621763 616520056 319573751 768714208 599576613 375571088 247564468 212172708 423186710 770359530 21894953 33324268 854225119 356890158 245203744 201520307 427181806 239829958 46111946 615424502 521543766 772667233...

output:

1999160607
1998430363
1998998115
1999454864
1999104431
1997495013
1999600913
1998339017
1999666999
1998257302
1999257565
1999686551
1998223010
1998816615
1998756577
1998268448
1999761220
1998054789
1998032099
1999441216
1998054189
1998884323
1998450136
1999063624
1999134388
1998203599
1997868958
199...

result:

ok 1000001 lines

Test #19:

score: -100
Wrong Answer
time: 141ms
memory: 15640kb

input:

1 1000000
578672810
419797124
955694590
114438853
1974869425
1959945244
1927637197
1101442047
298533757
2067317911
1312256868
996312379
968422904
538077951
661569152
562935822
527918651
1849610139
1330912793
231329643
1825667949
1506793409
1569459513
712734026
660132679
611759151
260054040
146588537...

output:

998469934
636724602
1168076905
1386694274
1223883592
1553296431
1068605562
1358478257
1312708560
579272030
1013076239
676887969
717746184
807872306
875067366
1306323591
1180696006
730446985
1220430988
1189941387
1101045748
1051356023
927921895
848559690
962798351
1499535297
817663405
691960660
12546...

result:

wrong answer 4059th lines differ - expected: '587950288', found: '0'