QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#228816#6416. Classical Scheduling Problemlsj2009TL 5983ms185236kbC++142.5kb2023-10-28 14:17:252023-10-28 14:17:27

Judging History

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

  • [2023-10-28 14:17:27]
  • 评测
  • 测评结果:TL
  • 用时:5983ms
  • 内存:185236kb
  • [2023-10-28 14:17:25]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
#define ll long long
#define ull unsigned long long
#define ld long double
#define PII pair<int,int>
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3f
#define chkmax(a,b) a=max(a,b)
#define chkmin(a,b) a=min(a,b)
#define rep(k,l,r) for(int k=l;k<=r;++k)
#define per(k,r,l) for(int k=r;k>=l;--k)
#define cl(f,x) memset(f,x,sizeof(f))
using namespace std;
const int N=2e5+5;
struct SGT {
	struct node {
		int lson,rson,val,cnt;
	}; node tree[N*30];
	#define ls(k) tree[k].lson
	#define rs(k) tree[k].rson
	int p;
	int new_node() {
		return ++p;
	}
	void init() {
		rep(i,1,p)
			tree[i]={0,0,0,0};
		p=0;
	}
	void push_up(int k) {
		tree[k].val=tree[ls(k)].val+tree[rs(k)].val;
		tree[k].cnt=tree[ls(k)].cnt+tree[rs(k)].cnt;
	}
	void update(int &k,int l,int r,int qx,int val) {
		if(!k)
			k=new_node();
		if(l==r) {
			tree[k].cnt+=val;
			tree[k].val+=val*l;
			return;
		}
		int mid=(l+r)>>1;
		if(qx<=mid)
			update(ls(k),l,mid,qx,val);
		else
			update(rs(k),mid+1,r,qx,val);
		push_up(k);
	}
	int query(int k,int l,int r,int rk) {
		if(l==r)
			return rk*l;
		int cnt=tree[ls(k)].cnt,val=tree[ls(k)].val;
		int mid=(l+r)>>1;
		if(cnt<rk)
			return val+query(rs(k),mid+1,r,rk-cnt);
		else
			return query(ls(k),l,mid,rk);
	}
}; SGT pre,suf;
int a[N],b[N],p[N],n,m;
PII t[N];
int check(int x) {
	pre.init(); suf.init();
	int prt=0,srt=0;
	rep(i,1,n) 
		suf.update(srt,1,1e9,a[i],1);
	rep(i,1,n) {
		suf.update(srt,1,1e9,a[i],-1);
		if(i>=x) {
			int k=max(b[i],x);
			if(n-i>=k-x) {
				if(pre.query(prt,1,1e9,x-1)+a[i]+suf.query(srt,1,1e9,k-x)<=m)
					return i;
			}
		}
		pre.update(prt,1,1e9,a[i],1);
	}
	return -1;
}
void print(int l,int r,int k) {
	vector<PII> vec;
	rep(i,l,r)
		vec.push_back({a[i],p[i]});
	sort(vec.begin(),vec.end());
	rep(i,0,k-1)
		printf("%lld ",vec[i].second);
}
signed main() {
	int T;
	scanf("%lld",&T);
	while(T--) {
		scanf("%lld%lld",&n,&m);
		rep(i,1,n)
			scanf("%lld%lld",&t[i].first,&t[i].second),p[i]=i;
		sort(p+1,p+n+1,[](const int &x,const int &y) {
			return t[x].second<t[y].second;
		});
		rep(i,1,n)
			a[i]=t[p[i]].first,b[i]=t[p[i]].second;
		int l=1,r=n,ans=0,pos=0;
		while(l<=r) {
			int mid=(l+r)>>1;
			int val=check(mid);
			if(val!=-1)
				ans=mid,pos=val,l=mid+1;
			else
				r=mid-1;
		}
		printf("%lld\n%lld\n",ans,max(ans,b[pos]));
		if(pos) {
			print(1,pos-1,ans-1);
			printf("%lld ",p[pos]);
			print(pos+1,n,max(ans,b[pos])-ans);
			puts("");
		}
	}
	return 0;
}

详细

Test #1:

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

input:

2
4 100
20 1
40 4
60 3
30 3
1 5
10 1

output:

2
3
1 4 2 
0
0

result:

ok ok, 2 test cases (2 test cases)

Test #2:

score: 0
Accepted
time: 472ms
memory: 9916kb

input:

10000
21 1892
174 13
604 15
170 2
413 11
899 2
531 12
651 17
553 9
429 8
837 14
937 12
577 7
532 11
19 2
173 10
165 6
762 15
221 6
945 13
302 19
7 3
54 26066
812 31
432 24
240 37
171 39
204 47
174 30
569 1
467 5
624 42
734 35
907 3
568 23
802 40
991 32
119 13
187 27
739 42
891 14
550 44
374 16
483 1...

output:

7
8
21 14 16 3 18 12 9 15 
53
53
22 25 37 41 15 27 4 6 48 16 54 5 31 3 38 42 43 44 51 35 20 2 8 30 21 52 19 34 12 7 26 9 53 33 36 46 47 10 24 49 17 40 45 39 13 1 32 23 18 50 11 14 29 
12
12
5 12 14 4 6 1 8 7 15 2 9 13 
7
14
40 8 41 14 13 1 28 38 21 37 24 11 43 33 
10
10
7 12 9 10 29 19 5 28 22 15 
0...

result:

ok ok, 10000 test cases (10000 test cases)

Test #3:

score: 0
Accepted
time: 400ms
memory: 8036kb

input:

10000
31 13863446
88657 7
999554 9
118529 26
847277 28
370661 19
261018 28
635679 10
228483 3
645280 9
476021 13
778546 23
325779 9
833392 1
328146 30
873417 6
327100 31
9792 26
327533 31
361518 30
74201 17
220223 12
395716 28
92721 14
296968 27
177176 14
698707 6
130653 14
639654 14
883578 27
94779...

output:

29
30
17 20 1 23 3 27 25 21 8 6 24 12 19 5 22 10 31 7 28 9 26 11 13 4 15 29 30 2 14 16 
4
4
2 4 3 5 
2
2
1 2 
6
7
10 13 25 18 3 17 4 
6
6
8 9 10 12 2 5 
0
0
13
13
1 9 8 11 13 5 10 2 7 15 4 12 6 
7
7
6 3 1 5 8 7 10 
12
15
6 21 10 8 12 7 18 5 15 16 9 20 14 3 19 
21
24
3 21 16 11 8 14 23 2 4 26 1 15 25...

result:

ok ok, 10000 test cases (10000 test cases)

Test #4:

score: 0
Accepted
time: 417ms
memory: 8004kb

input:

10000
1 148649924
152343597 1
23 2873231053
341227727 2
97244309 22
382344096 18
92079917 18
716353906 4
963429195 14
131618841 1
637584871 10
210001357 11
578579097 4
246465963 6
968391199 2
950133297 8
509339869 18
427327942 11
542440792 6
451945776 11
62800058 4
275583515 14
347078482 12
49062133...

output:

0
0
7
7
18 7 1 16 10 5 11 
58
59
10 30 1 40 44 53 28 37 35 34 3 22 61 50 17 38 60 55 29 33 20 2 43 24 56 47 15 49 16 26 31 58 51 27 39 12 52 14 19 4 7 11 25 59 23 46 42 9 21 41 45 62 54 48 5 8 36 6 32 
6
7
8 2 4 1 9 14 10 
0
0
0
0
8
8
8 3 4 1 9 7 6 2 
9
11
16 11 9 24 10 12 4 15 26 21 18 
12
12
8 10 ...

result:

ok ok, 10000 test cases (10000 test cases)

Test #5:

score: 0
Accepted
time: 830ms
memory: 9116kb

input:

1000
82 7692098567
820091633 60
355742811 58
33274857 31
608429291 33
997797811 20
467502732 30
853286378 8
652795874 46
342018780 22
758395270 23
273397259 44
363579524 49
911951022 78
19637469 55
648691248 73
289596934 53
538807472 31
612554087 13
925583232 12
934115550 2
348467623 19
793103161 30...

output:

22
31
3 44 70 55 56 30 78 46 76 79 39 9 21 38 24 73 6 72 65 23 18 17 14 81 48 50 69 59 36 33 41 
333
336
209 291 121 124 245 155 159 179 200 57 251 132 163 284 119 69 105 268 25 260 206 300 207 117 228 304 127 14 44 281 214 233 108 311 263 294 232 205 59 168 279 140 160 306 248 62 52 314 315 254 246...

result:

ok ok, 1000 test cases (1000 test cases)

Test #6:

score: 0
Accepted
time: 1410ms
memory: 22468kb

input:

100
1903 595649261976
242016788 1493
744829262 608
858593044 1816
156659209 1534
114991300 737
762579703 695
727190226 706
259042985 1281
43413203 314
845442517 462
566008000 1873
396423639 557
642518388 234
224641323 1517
952294191 985
706509300 1598
600896534 1474
40659577 676
385404080 236
626269...

output:

1277
1425
943 573 79 1221 326 496 868 130 555 169 1393 36 1305 650 1588 1784 1873 1017 1893 755 293 309 1106 1219 702 873 525 959 192 569 1228 968 1076 1080 1423 761 1169 1406 1652 859 221 1531 1356 506 581 528 28 1374 1789 1717 587 520 1448 413 1790 955 381 1575 947 1691 1833 1064 129 1719 18 1634 ...

result:

ok ok, 100 test cases (100 test cases)

Test #7:

score: 0
Accepted
time: 2540ms
memory: 65568kb

input:

10
44263 8178145065835
144776695 4988
633784692 681
124897155 10140
486257408 37126
851769386 39526
842969054 41273
255566344 35680
453250390 22330
451088941 12204
619362016 38143
532744479 19473
674895021 28375
9336149 42718
66645534 4600
788583869 43466
74789962 44203
394416695 18040
400692349 209...

output:

18932
24297
17897 4413 4158 14060 43676 19100 21721 8162 30910 39141 14624 21509 31041 28256 29019 32495 27323 38853 13366 27931 28786 20149 11045 10832 23820 11055 38922 20269 30714 5769 22568 37604 19666 36323 21023 27197 34028 44062 10490 16638 20063 27639 20740 16242 6272 43260 22182 5668 260 35...

result:

ok ok, 10 test cases (10 test cases)

Test #8:

score: 0
Accepted
time: 4856ms
memory: 183672kb

input:

1
200000 57702603292869
895088145 19931
718152698 145634
769081244 195129
55087510 17432
215103308 38922
856865039 8045
427652731 169525
293884192 171894
21414244 46946
623839144 178383
12560296 182397
24930343 41111
35462858 35129
835318852 151986
599094451 25610
510310473 182086
13017134 125354
31...

output:

125582
143872
66285 80280 56819 31467 135652 36171 118991 198601 85843 135213 134776 188784 18198 71107 194225 151216 161225 133070 138243 163171 87542 181967 191554 95587 78111 126688 183384 38740 91941 117219 23905 85663 41155 124374 55593 127461 113427 122690 1367 169649 31783 198110 193254 47468...

result:

ok ok, 1 test cases (1 test case)

Test #9:

score: 0
Accepted
time: 4691ms
memory: 184652kb

input:

1
200000 12588150171192
697033205 186664
970477791 19327
89605019 14812
737206044 50478
873649284 20706
932998866 56365
904409119 123817
622032436 43875
690673101 87090
321866772 190284
480046085 18004
398840764 188598
65227144 174007
747187240 89799
347289225 42777
525044511 113973
443965741 85452
...

output:

35303
58673
88475 133903 190404 77193 4659 143921 137350 155769 20045 129683 41067 121995 25213 165456 177420 111611 3889 27236 1326 7046 142608 82680 76725 62528 191005 8816 147067 164626 35741 179955 53849 167396 182801 52811 157521 91920 84880 94437 119551 119608 71669 146925 43629 147830 197185 ...

result:

ok ok, 1 test cases (1 test case)

Test #10:

score: 0
Accepted
time: 4477ms
memory: 184364kb

input:

1
200000 10006366792128
443157143 37820
891603781 189849
777301083 136035
751373772 66490
129295230 83820
856462092 153518
90933608 121576
985421539 171766
894499409 15340
504842122 150235
220633943 37522
599038908 146919
95632289 63799
846784841 64938
366209521 142907
786525536 3703
811575655 14202...

output:

29564
51591
177192 34969 126791 187188 187670 106197 131909 139549 83060 193357 193881 193739 43181 63115 107289 168761 114068 192675 150307 189876 62006 166246 65273 96824 104502 50312 62850 2005 176149 114796 69275 167769 160168 39670 148254 17599 33348 111455 144023 158075 196958 76416 130924 658...

result:

ok ok, 1 test cases (1 test case)

Test #11:

score: 0
Accepted
time: 5175ms
memory: 183864kb

input:

1
200000 59325562957383
597693992 88976
705975556 136180
769285809 57258
925484458 82502
934515757 179637
34493116 193774
292497126 127847
927349507 123849
421832595 135078
86561264 85994
324999063 89744
343030484 72536
478691338 120886
821844439 48589
559996659 43036
315388256 117624
403103475 1985...

output:

128371
145900
109259 94237 149561 139989 65931 84253 69031 33914 68032 112889 192178 192894 186498 30297 126377 130128 62881 37623 83851 65377 159016 54324 104171 65835 15849 92111 53689 114333 190226 199751 179225 111555 190177 23523 103013 123914 199952 111313 187781 90417 55622 196624 139036 3035...

result:

ok ok, 1 test cases (1 test case)

Test #12:

score: 0
Accepted
time: 5046ms
memory: 182640kb

input:

1
200000 31416577732624
340512981 172835
292213892 73998
597003807 154289
318028093 98514
699376263 108159
718827833 34030
170900966 125605
621404415 43228
741228044 63328
772056878 189049
376794916 166159
867292793 30857
509371589 34870
262300647 191024
885419246 143166
285220760 7354
455026503 551...

output:

75413
101049
58620 80413 198744 130885 121975 93115 61231 30199 131466 78810 52012 30634 49069 95775 128227 37818 135745 186228 89582 4340 45856 44150 73553 22868 105484 167142 177873 12047 69058 158881 21082 145301 142444 64613 89847 160386 28903 113596 102099 76628 74302 28066 182518 115203 37291 ...

result:

ok ok, 1 test cases (1 test case)

Test #13:

score: 0
Accepted
time: 4917ms
memory: 183296kb

input:

1
200000 77196200005652
81679500 15479
628507583 44521
548869801 108216
202160806 81822
13811372 171273
182622346 74287
999301204 131876
340742380 195311
535907253 183066
856296272 149001
972508704 18381
165273242 132281
159309262 124662
873186151 141971
205568022 108704
407608325 121275
550726777 7...

output:

160837
171651
80980 166932 181906 150130 166120 110746 34370 144018 53317 87933 115044 74843 856 172900 119143 54541 39517 21710 79732 151999 189087 154639 192622 162143 69623 54203 111900 188377 100163 150358 89061 76247 64290 268 20396 158951 142365 116351 159497 130543 103561 106820 94872 192054 ...

result:

ok ok, 1 test cases (1 test case)

Test #14:

score: 0
Accepted
time: 3857ms
memory: 185236kb

input:

1
200000 1429350937284
526226223 66634
289923614 182339
134908142 29440
973080309 130538
582853772 67091
195951976 147247
137707811 162339
365463069 147394
380937199 144019
634246766 52056
307148783 70603
942004511 57898
3571365 14454
359533636 117110
505575330 33026
877559277 43709
315326693 135586...

output:

6240
16911
169483 102267 95796 3761 185272 155302 14891 58653 169217 45673 140349 118257 22151 196437 137276 169766 111620 66235 187330 83184 125031 135677 154264 20288 83382 6960 150163 32394 194536 2048 5683 151651 9270 95538 197896 70232 58730 102412 6939 37450 62358 128610 195858 13 52867 168352...

result:

ok ok, 1 test cases (1 test case)

Test #15:

score: 0
Accepted
time: 5227ms
memory: 182400kb

input:

1
200000 39468068349617
969120466 150494
24726062 152861
521763411 159175
558919972 113846
111536151 195612
168882091 11695
701218828 135906
443830562 75285
737929800 63757
515973716 179303
214070560 147017
369040750 16219
495454680 95733
311277733 92249
952085762 133155
118363682 124927
505405455 1...

output:

91018
113879
50609 65796 182016 123957 160725 116566 171566 107477 120664 62917 143532 11197 181528 27677 175959 97796 141057 185775 147424 65654 129278 85022 154993 162951 67504 179670 24641 122868 131162 160700 121148 149677 17480 154605 6629 119902 73154 52985 142771 3570 28916 38592 156838 17828...

result:

ok ok, 1 test cases (1 test case)

Test #16:

score: 0
Accepted
time: 5331ms
memory: 182548kb

input:

1
200000 31680217124307
410362237 1650
769634917 66488
96046721 80398
716530488 129858
253073129 58726
691347343 84656
984801589 166368
217597531 27368
698528858 192007
386379101 82358
959877570 199240
764803504 141836
339991881 152821
433451122 43196
931710433 33285
806690407 14656
444294191 16018
...

output:

75884
100960
168726 14579 143301 130826 166433 181818 133950 52078 67518 92587 67982 184018 158836 16847 160433 92176 61608 189023 160679 185543 90250 83553 160784 130718 4326 194471 54862 134560 76300 181270 23078 150064 181101 47812 119557 100609 108425 138925 98462 61328 74717 182403 169412 13926...

result:

ok ok, 1 test cases (1 test case)

Test #17:

score: 0
Accepted
time: 5558ms
memory: 183344kb

input:

1
200000 50189655538839
144918862 85509
874582319 37010
622923939 1621
680745970 178574
362565239 154544
173413093 124912
283423444 107231
626630752 179450
162775379 111745
65593607 18117
954635150 51462
934284433 100157
127117617 42613
431086468 185631
504582560 166119
807664334 161282
542058258 39...

output:

111328
132020
157413 89393 170292 120787 120391 184560 609 6604 141060 25360 1472 149794 79608 151869 188690 147217 181183 106506 121799 69948 162622 71293 170259 73000 178 56105 7413 12560 11099 152714 2943 168903 121876 175336 102899 92563 21454 123329 94815 141101 88043 158645 197404 78196 179168...

result:

ok ok, 1 test cases (1 test case)

Test #18:

score: 0
Accepted
time: 4117ms
memory: 182608kb

input:

1
200000 27981446446585
582855670 103961
141413192 7533
273949246 131356
958444006 161882
431697304 83066
615079319 165168
918652616 113502
177807831 98829
514133749 7290
232048977 178069
876775045 127876
877483551 168877
266897215 132405
894118428 160771
163824546 66248
614407879 51011
300135242 96...

output:

68351
93640
19262 37138 170214 154879 143361 161040 195466 62186 165139 175376 85042 87622 159161 17302 54765 77594 96947 133389 151245 20044 104923 98759 106635 160280 185139 2382 19970 93485 182330 176907 112160 155661 111804 8215 92406 130325 91931 88267 174649 96974 154558 59854 187381 120417 14...

result:

ok ok, 1 test cases (1 test case)

Test #19:

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

input:

1
1 1
1 1

output:

1
1
1 

result:

ok ok, 1 test cases (1 test case)

Test #20:

score: 0
Accepted
time: 2233ms
memory: 18644kb

input:

1
200000 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1...

output:

1
1
133339 

result:

ok ok, 1 test cases (1 test case)

Test #21:

score: 0
Accepted
time: 1918ms
memory: 13280kb

input:

1
200000 1
1 200000
1 200000
1 200000
1 200000
1 200000
1 200000
1 200000
1 200000
1 200000
1 200000
1 200000
1 200000
1 200000
1 200000
1 200000
1 200000
1 200000
1 200000
1 200000
1 200000
1 200000
1 200000
1 200000
1 200000
1 200000
1 200000
1 200000
1 200000
1 200000
1 200000
1 200000
1 200000
1...

output:

0
0

result:

ok ok, 1 test cases (1 test case)

Test #22:

score: 0
Accepted
time: 1403ms
memory: 12704kb

input:

1
200000 1
1000000000 1
1000000000 1
1000000000 1
1000000000 1
1000000000 1
1000000000 1
1000000000 1
1000000000 1
1000000000 1
1000000000 1
1000000000 1
1000000000 1
1000000000 1
1000000000 1
1000000000 1
1000000000 1
1000000000 1
1000000000 1
1000000000 1
1000000000 1
1000000000 1
1000000000 1
100...

output:

0
0

result:

ok ok, 1 test cases (1 test case)

Test #23:

score: 0
Accepted
time: 1069ms
memory: 13052kb

input:

1
200000 1
1000000000 200000
1000000000 200000
1000000000 200000
1000000000 200000
1000000000 200000
1000000000 200000
1000000000 200000
1000000000 200000
1000000000 200000
1000000000 200000
1000000000 200000
1000000000 200000
1000000000 200000
1000000000 200000
1000000000 200000
1000000000 200000
1...

output:

0
0

result:

ok ok, 1 test cases (1 test case)

Test #24:

score: 0
Accepted
time: 2018ms
memory: 16976kb

input:

1
200000 200000000000000
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1...

output:

200000
200000
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 9...

result:

ok ok, 1 test cases (1 test case)

Test #25:

score: 0
Accepted
time: 1940ms
memory: 16824kb

input:

1
200000 200000000000000
1 200000
1 200000
1 200000
1 200000
1 200000
1 200000
1 200000
1 200000
1 200000
1 200000
1 200000
1 200000
1 200000
1 200000
1 200000
1 200000
1 200000
1 200000
1 200000
1 200000
1 200000
1 200000
1 200000
1 200000
1 200000
1 200000
1 200000
1 200000
1 200000
1 200000
1 200...

output:

200000
200000
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 9...

result:

ok ok, 1 test cases (1 test case)

Test #26:

score: 0
Accepted
time: 1105ms
memory: 18460kb

input:

1
200000 200000000000000
1000000000 1
1000000000 1
1000000000 1
1000000000 1
1000000000 1
1000000000 1
1000000000 1
1000000000 1
1000000000 1
1000000000 1
1000000000 1
1000000000 1
1000000000 1
1000000000 1
1000000000 1
1000000000 1
1000000000 1
1000000000 1
1000000000 1
1000000000 1
1000000000 1
10...

output:

200000
200000
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 9...

result:

ok ok, 1 test cases (1 test case)

Test #27:

score: 0
Accepted
time: 1122ms
memory: 15320kb

input:

1
200000 200000000000000
1000000000 200000
1000000000 200000
1000000000 200000
1000000000 200000
1000000000 200000
1000000000 200000
1000000000 200000
1000000000 200000
1000000000 200000
1000000000 200000
1000000000 200000
1000000000 200000
1000000000 200000
1000000000 200000
1000000000 200000
10000...

output:

200000
200000
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 9...

result:

ok ok, 1 test cases (1 test case)

Test #28:

score: 0
Accepted
time: 1058ms
memory: 11504kb

input:

1
200000 100000000000000
1000000000 200000
1000000000 200000
1000000000 200000
1000000000 200000
1000000000 200000
1000000000 200000
1000000000 200000
1000000000 200000
1000000000 200000
1000000000 200000
1000000000 200000
1000000000 200000
1000000000 200000
1000000000 200000
1000000000 200000
10000...

output:

0
0

result:

ok ok, 1 test cases (1 test case)

Test #29:

score: 0
Accepted
time: 2ms
memory: 9824kb

input:

1
10 299
10 2
53 7
83 9
15 3
28 4
47 9
75 2
62 9
23 5
8 4

output:

7
7
10 1 4 9 5 7 2 

result:

ok ok, 1 test cases (1 test case)

Test #30:

score: 0
Accepted
time: 6ms
memory: 10124kb

input:

1
1000 1841609
5209 422
7129 618
893 700
8231 647
9844 314
6789 347
3968 711
5864 416
9564 190
7357 874
530 87
7935 754
3475 772
2898 206
9252 717
6604 686
7451 188
9366 977
6294 618
3919 454
8164 232
8617 403
5257 191
8554 626
1727 952
205 759
3312 453
4798 387
7005 774
3570 892
3034 45
5101 466
59...

output:

447
546
909 481 480 788 513 605 366 207 173 197 647 211 347 448 93 161 652 126 116 327 886 739 840 355 537 957 773 382 945 619 192 408 854 354 200 11 923 696 756 519 52 33 151 643 424 932 64 140 467 350 339 335 107 226 618 968 484 682 583 377 857 222 328 941 697 406 474 789 726 209 372 106 571 562 9...

result:

ok ok, 1 test cases (1 test case)

Test #31:

score: 0
Accepted
time: 4468ms
memory: 182636kb

input:

1
200000 24577580970703
656715015 199803
956780431 189922
293564365 139627
914941210 61288
941205521 178624
674601481 87247
173334239 146057
362284792 31141
248508805 184184
947672840 51295
400265751 140002
24148576 188821
351568365 57409
787832999 113156
743686688 21173
841349516 186123
902806032 1...

output:

61504
87275
123472 99263 141621 146581 51026 194880 131616 32657 130611 70056 90028 84488 101462 57171 121008 21433 74878 64725 136223 106388 92210 63925 25590 114054 50539 182735 38508 7601 158847 59384 21293 59561 82557 103011 165319 21856 54860 103081 45925 101139 122953 57490 22215 59828 16633 1...

result:

ok ok, 1 test cases (1 test case)

Test #32:

score: 0
Accepted
time: 5983ms
memory: 179388kb

input:

1
200000 1623
691944610 133408
244110549 35622
820275739 179459
22018946 195637
22760475 51629
637640711 69587
123326171 136444
892528944 106021
356879446 183488
912241290 119398
275436827 84437
453945181 70240
947197540 100566
283979992 64330
473324390 69248
312572302 43326
652302826 107367
1211581...

output:

0
0

result:

ok ok, 1 test cases (1 test case)

Test #33:

score: 0
Accepted
time: 3989ms
memory: 183092kb

input:

1
200000 33514678169931
121677529 31920
777971499 187969
617049720 137098
419390184 75721
955778107 128696
17132807 165192
553423875 166900
689515597 177311
658315212 123015
948476705 37132
651978953 125843
605923663 59539
199020236 165777
475699208 189135
559018475 136876
469474861 91887
376859744 ...

output:

52536
108148
161124 9504 37220 130523 166540 73248 110127 63974 22371 35524 16045 23148 3378 143060 132851 43592 149958 36144 8772 1185 190307 45387 187896 107786 120116 122698 103095 25423 8003 36184 47788 50387 160982 2674 188638 23311 3273 173487 93361 120318 97651 160387 41556 117000 187307 1563...

result:

ok ok, 1 test cases (1 test case)

Test #34:

score: 0
Accepted
time: 2ms
memory: 9812kb

input:

1
5 455
70 2
90 5
69 3
93 1
98 3

output:

5
5
3 1 4 5 2 

result:

ok ok, 1 test cases (1 test case)

Test #35:

score: 0
Accepted
time: 2ms
memory: 9900kb

input:

1
100 23591
888 17
792 51
685 47
182 3
102 61
555 48
771 56
712 1
580 78
342 31
285 33
525 99
537 25
929 18
84 53
104 88
624 55
253 3
201 53
536 95
65 84
540 5
549 52
248 77
677 5
431 50
600 80
328 46
134 29
526 83
500 3
400 63
276 23
570 4
410 57
507 58
984 20
486 44
802 54
985 11
635 3
96 83
855 9...

output:

54
63
98 50 67 55 88 96 15 5 61 29 85 4 19 46 18 59 33 11 28 92 10 51 35 80 26 90 71 79 38 31 36 13 74 22 23 69 6 34 82 17 58 41 63 25 3 54 62 60 8 94 52 7 2 32 95 49 21 42 16 44 87 81 78 

result:

ok ok, 1 test cases (1 test case)

Test #36:

score: 0
Accepted
time: 63ms
memory: 12588kb

input:

1
10000 60845880
2292 5988
3420 4026
5243 3246
4223 41
682 468
1497 5008
1573 584
5848 7049
5555 4129
9311 9957
6065 7225
3569 9498
717 1695
9690 1968
8700 7557
5142 9427
8788 371
9576 2260
4322 2674
5829 7448
982 9123
438 7591
9459 1590
5002 5982
4144 243
9585 4254
6745 9988
9602 3691
9518 2297
981...

output:

10000
10000
6169 7991 7753 4160 761 4633 2535 1398 9898 321 336 9729 6422 7358 5394 1834 419 4744 8199 2927 1008 4300 7338 9155 5323 1074 7045 1707 4478 2824 90 4275 4872 5176 3181 407 5457 6949 4530 6045 7790 2046 9481 6727 8913 197 2738 8371 5992 5813 7397 6159 8571 4437 7098 678 4365 5145 260 400...

result:

ok ok, 1 test cases (1 test case)

Test #37:

score: 0
Accepted
time: 5253ms
memory: 184600kb

input:

1
200000 196479508615078
28295282 200000
911267508 200000
236024810 200000
513346768 200000
741720858 200000
685888445 200000
495085242 200000
953023631 200000
348674792 200000
523272031 200000
459044409 200000
210045061 200000
88248849 200000
259363079 200000
418405428 200000
100223051 200000
93933...

output:

200000
200000
27338 95756 43135 179802 111202 113455 30845 56161 26981 49543 157756 122640 59071 146999 139480 62571 26206 188516 40408 72255 19776 10737 172448 64993 148173 141675 108352 82558 141489 62095 128715 70007 52416 135040 165524 19712 96071 128250 16352 173535 134760 175484 102922 178922 ...

result:

ok ok, 1 test cases (1 test case)

Test #38:

score: 0
Accepted
time: 5510ms
memory: 184564kb

input:

1
200000 135707572511546
494679362 71529
380066098 40582
143567817 95803
319571661 41447
140442890 109991
585350811 68216
440239975 61921
37969390 100431
367093317 172161
544275807 38054
156617869 107523
391904071 32538
621381932 113096
385142855 166446
176514963 101396
26497984 84041
930946615 1459...

output:

200000
200000
53738 64628 66599 185372 127055 181310 110645 199771 99243 31749 162684 19273 47857 57168 176461 20785 33649 29610 31915 34729 80701 181362 109589 140245 92038 86649 107703 158377 88976 165126 162227 140752 60086 12706 176270 157083 2231 146443 29032 189354 166059 185633 120873 78225 6...

result:

ok ok, 1 test cases (1 test case)

Test #39:

score: 0
Accepted
time: 5437ms
memory: 183136kb

input:

1
200000 161950750594970
793492620 20373
359415351 102763
18563992 141876
540505816 25435
519736034 181469
228183605 27960
807434490 121058
171474009 172540
535491335 19719
691339555 102294
376758082 22597
119250632 74217
629443449 23304
263632975 158603
944034189 1266
870807571 2823
341748724 89430...

output:

200000
200000
19531 17767 122350 82500 147377 88335 138609 26522 57221 161303 147254 47761 95587 98024 86094 107077 41270 150862 197194 87265 1069 1935 23318 159171 40535 106092 9679 116470 113102 175175 139053 188322 155922 58838 65958 77528 199650 77903 23464 169378 34134 160565 63201 71094 24908 ...

result:

ok ok, 1 test cases (1 test case)

Test #40:

score: 0
Accepted
time: 5447ms
memory: 185168kb

input:

1
200000 188193928678394
532497366 169218
193540413 99537
748335976 20653
171505380 42127
193996474 85651
165983695 155000
324372109 90595
159754435 20457
408922057 124173
838403304 199239
746641400 3079
141564489 148600
342537670 133513
582314583 40360
856777607 101136
569892967 113094
752550833 65...

output:

200000
200000
96037 44194 144752 93141 104956 13552 50071 116550 180638 105422 123552 104948 32955 184562 26645 32432 22464 43402 189628 102344 192710 123401 169273 123433 46482 127671 5119 197682 112188 123613 95727 184224 27507 90833 100079 185786 175856 104724 103089 27112 126900 157148 19982 538...

result:

ok ok, 1 test cases (1 test case)

Test #41:

score: 0
Accepted
time: 4389ms
memory: 183152kb

input:

1
200000 14432811794522
126277919 118062
172889666 129014
623332151 123621
392439535 193411
868256913 22538
958559593 90551
691566624 117029
443002158 68374
577320075 171732
130691244 39288
261748909 126665
163878346 190280
55631891 52233
165837408 65221
329329537 1006
119235258 23364
308577134 1762...

output:

39637
64015
84103 72063 122200 143977 17257 25037 28980 182027 76772 107676 68484 50829 130954 66943 56105 57939 28362 54846 120737 11995 136608 76099 7295 110825 98099 111784 184199 83421 199638 174387 122781 30189 184999 109270 12393 93674 141664 96565 129187 5521 102004 101720 129632 128999 91138...

result:

ok ok, 1 test cases (1 test case)

Test #42:

score: 0
Accepted
time: 4067ms
memory: 183488kb

input:

1
200000 40671694910650
865282665 66906
152238920 15388
58136838 169694
613373691 177399
542517353 94016
601392388 17591
913536947 86566
871474072 148996
745718094 51994
982787697 136233
776856418 74442
891224907 88855
63693408 162441
189551720 81570
391816059 11277
963544845 76738
424411946 152431
...

output:

93719
116281
162183 69168 30123 191034 149806 126111 19872 97844 56635 51613 151963 107910 8090 190064 38866 71429 96840 172097 104296 45680 187408 28350 153762 47447 194146 40995 10424 1796 185486 66566 117482 68316 182908 64937 71102 130317 37239 12068 118338 13776 182142 97264 114970 73861 86294 ...

result:

ok ok, 1 test cases (1 test case)

Test #43:

score: 0
Accepted
time: 4998ms
memory: 184892kb

input:

1
200000 66919167961370
164095923 183047
281331278 44866
82876118 48471
539340550 194091
216777792 198198
539192478 10039
135507270 112999
154721794 196913
619148816 123744
129851445 33178
586931224 22220
913538764 130534
776787630 72649
363009136 139135
304559478 111147
807854432 19713
540246759 95...

output:

142487
157397
193139 91390 174775 20314 14923 124028 144980 133204 176792 91937 49741 167835 121682 129668 169337 77755 30875 192915 193514 189716 117426 26540 74904 141125 50147 122764 124921 158916 185135 175136 80337 20239 82903 75718 98427 39949 67463 193922 109868 85120 190748 82774 139750 6138...

result:

ok ok, 1 test cases (1 test case)

Test #44:

score: 0
Accepted
time: 4658ms
memory: 183452kb

input:

1
200000 93158051077498
462909180 107699
260680531 107047
662904997 118736
760274706 145375
596070936 135084
771959864 137078
502701786 82536
288226413 69022
492579538 171302
422139386 105930
956814541 145806
935852621 37621
194914555 191370
386723449 163996
72078704 11017
917005235 105791
96273060 ...

output:

188497
191721
104520 148615 102092 29641 143309 124869 71383 180832 2239 62940 94959 159025 43192 104289 145840 37566 140246 80817 161769 194571 33160 124983 168521 187115 132712 91471 11989 152879 101555 159274 2079 16773 51587 35993 130909 68060 82020 65044 94477 176273 118522 97199 48068 122724 9...

result:

ok ok, 1 test cases (1 test case)

Test #45:

score: 0
Accepted
time: 5039ms
memory: 183336kb

input:

1
200000 119401229160922
201913926 56544
94805593 136525
392676980 30217
981208861 162067
125107184 6563
414792658 72630
724672109 108970
276506839 116939
660977556 75757
569203134 170171
471922050 126288
368231886 79301
202976072 134282
410437761 13049
839597930 110888
761314822 183358
507075169 15...

output:

200000
200000
93762 8854 65302 23034 8787 45076 43160 97047 166449 179218 114900 106841 89723 124480 23561 113848 170443 161154 1803 38982 37637 75326 17365 38090 127711 87967 4986 142369 126524 87760 117657 23274 191559 92170 114263 105630 148386 102000 5165 70326 94793 161286 182862 76908 70810 19...

result:

ok ok, 1 test cases (1 test case)

Test #46:

score: 0
Accepted
time: 5054ms
memory: 183932kb

input:

1
200000 145644407244346
795694480 5388
74154846 198707
562640451 108993
907175721 146055
799367623 110745
352592749 199670
91866624 111211
704978754 164856
534408278 123315
716266883 10220
987029559 41361
535769935 153684
916070293 44490
288927881 37910
752341348 178054
310657113 69436
622909981 19...

output:

200000
200000
191965 196946 122105 85526 184488 192086 29403 2277 47083 36097 22714 177354 60322 120325 119731 199781 170305 146725 137139 180755 122952 9270 17489 123434 111332 119088 81114 184318 27246 121932 144704 172123 20184 189176 163636 27043 54576 162313 3009 123865 130879 195542 42753 1578...

result:

ok ok, 1 test cases (1 test case)

Test #47:

score: 0
Accepted
time: 4681ms
memory: 183316kb

input:

1
200000 70911083548450
803317251 75107
716223859 91630
836314626 44291
950150561 11320
159203924 64308
417716260 8836
730647129 115695
30845928 90055
195585834 108993
899509967 67400
485422609 168141
703377963 82018
186329868 39752
538996040 28550
549807438 31612
111637472 136119
686751167 145605
2...

output:

149582
162664
15275 186598 84544 16801 36977 27729 14244 50545 144631 79765 113201 76139 102509 8845 84761 107519 184765 138961 153595 198959 36104 10816 195584 115404 131549 108235 104012 27638 33084 132941 159283 19501 2803 52468 197819 164991 178529 134223 140183 195698 48214 710 112104 146915 72...

result:

ok ok, 1 test cases (1 test case)

Test #48:

score: 0
Accepted
time: 5894ms
memory: 179284kb

input:

1
200000 11360
913315249 43565
482085213 37293
624340207 36798
745451871 183459
676955650 133760
364482503 43870
969041965 117574
679238595 95441
151880822 56729
548261894 140810
849277252 170062
755114771 116498
89493571 78714
574692282 88032
221846155 195147
806241251 109535
594765056 2956
4951136...

output:

0
0

result:

ok ok, 1 test cases (1 test case)

Test #49:

score: -100
Time Limit Exceeded

input:

1
200000 22057
817744879 522
279910080 20466
720059878 51052
578147780 126966
614108988 3870
771342312 5819
241067400 173391
814757759 176733
320724054 18903
506690710 73674
744091010 23797
277893485 65103
351251657 147112
526756898 140587
305596060 50683
380433327 66459
744620599 61420
832194582 11...

output:


result: