QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#373267#3099. Bodyguardoscaryang100 ✓3767ms717244kbC++203.3kb2024-04-01 13:37:122024-04-01 13:37:13

Judging History

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

  • [2024-04-01 13:37:13]
  • 评测
  • 测评结果:100
  • 用时:3767ms
  • 内存:717244kb
  • [2024-04-01 13:37:12]
  • 提交

answer

#include<bits/stdc++.h>

#define i128 __int128
#define vc vector
#define pb emplace_back
#define pii pair<int, int>
#define mkp make_pair
#define tup tuple<int, int, int>
#define mkt make_tuple
#define rep(i, a, b) for(int i = (a); i <= (b); ++i)
#define lep(i, a, b) for(int i = (a); i >= (b); --i)

#define int long long

using namespace std;

mt19937 gen(time(0));

inline int read() {
	int x = 0, w = 0; char ch = getchar(); while(!isdigit(ch)) w |= (ch == '-'), ch = getchar();
	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = getchar(); return w ? -x : x; 
}
inline void write(int x) { if(x > 9) write(x / 10); putchar(x % 10 + '0'); }
inline void writee(int x) { write(x); putchar(10); }

const int N = 6005, M = 3e6 + 5;

int n, m, tot, val[N], r[N][N], c[N][N];
int lx, ly, X[N], Y[N];
int ans[M], f[N][N];
pii s[N], t[N]; 
vc<tup> q[N][N];

inline void trans(pii &u) { auto [x, y] = u; u.first = x + y; u.second = y - x; }
inline int findx(int x) { return lower_bound(X + 1, X + 1 + lx, x) - X; }
inline int findy(int y) { return lower_bound(Y + 1, Y + 1 + ly, y) - Y; }

inline void init_grid() {
	for(int i = 1, t, a, b; i <= n; i++) {
		t = read(); a = read(); b = read(); val[i] = read() / 2;
		s[i] = mkp(a, t); ::t[i] = mkp(b, t + abs(a - b));
		trans(s[i]); trans(::t[i]);
		X[++lx] = s[i].first; Y[++ly] = s[i].second;
		X[++lx] = ::t[i].first; Y[++ly] = ::t[i].second;
	}
	sort(X + 1, X + 1 + lx); lx = unique(X + 1, X + 1 + lx) - X - 1;
	sort(Y + 1, Y + 1 + ly); ly = unique(Y + 1, Y + 1 + ly) - Y - 1;
	rep(i, 1, n) {
		auto &[sx, sy] = s[i];
		auto &[tx, ty] = t[i];
		sx = findx(sx); sy = findy(sy);
		tx = findx(tx); ty = findy(ty);
		if(sx == tx) { rep(j, sy, ty - 1) c[sx][j] = max(c[sx][j], val[i]); }
		else         { rep(j, sx, tx - 1) r[j][sy] = max(r[j][sy], val[i]); }
	}
}

inline void init_query() {
	for(int i = 1, t, u, x, y; i <= m; i++) {
		t = read(); u = read(); 
		x = findx(u + t); y = findy(t - u);
		if(x > lx || y > ly) continue;
		q[x][y].pb(mkt(i, X[x] - (u + t), Y[y] - (t - u)));
	}
}

inline void init_f() {
	lep(j, ly, 1) lep(i, lx, 1) 
		f[i][j] = max(f[i + 1][j] + (X[i + 1] - X[i]) * r[i][j], f[i][j + 1] + (Y[j + 1] - Y[j]) * c[i][j]);
}

struct convex {
	vc<pii> a; int tl;
	convex() { a.clear(); tl = 0; }
	inline void push(pii u) {
		while(tl && a[tl - 1].first <= u.first) --tl, a.pop_back();
		while(tl > 1 && (i128)(u.second - a[tl - 1].second) * (a[tl - 2].first - a[tl - 1].first) 
		              > (i128)(a[tl - 1].second - a[tl - 2].second) * (a[tl - 1].first - u.first)) a.pop_back(), --tl;
		a.pb(u); ++tl;
	}
	inline int ask(int k) {
		if(!tl) return 0;
		int l = 1, r = tl - 1, mid;
		while(l <= r) {
			mid = l + r >> 1;
			if((i128)(a[mid].second - a[mid - 1].second) <= (i128)k * (a[mid - 1].first - a[mid].first)) r = mid - 1;
			else l = mid + 1;
		}
		return k * a[r].first + a[r].second;
	}
} Q[N];

inline void solve() {
	lep(j, ly, 1) {
		convex row; 
		lep(i, lx, 1) {
			row.push(mkp(c[i][j - 1], f[i][j]));
			Q[i].push(mkp(r[i - 1][j], f[i][j]));
			for(auto [id, u, v] : q[i][j]) {
				ans[id] = max(ans[id], Q[i].ask(u));
				ans[id] = max(ans[id], row.ask(v));
			}
		}
	}
}

signed main() {
	n = read(); m = read();
	
	init_grid();
	init_f();
	init_query();	
	
	solve();
	
	rep(i, 1, m) writee(ans[i]);
	
	return 0;
}

詳細信息

Subtask #1:

score: 6
Accepted

Test #1:

score: 6
Accepted
time: 2475ms
memory: 415524kb

input:

2800 3000000
1492 2258 1809 338293100
1377 110 154 123380316
2303 103 2609 548687984
2540 553 952 507761442
2515 1067 1822 369936196
2394 1386 865 523125368
1582 2851 1552 143762392
198 1506 1513 116520542
163 1110 1065 186586932
2568 2350 185 145028620
1329 1070 1448 643824880
1024 2570 497 3127643...

output:

3619425557626
4487285315023
4279541502255
3168619360923
4387923824912
2789725470046
4499794599783
2877366785021
3327426177204
3520637576134
3014090640883
4694871083300
4054721753248
3238911920096
3109018148410
4919584154026
2427986680754
2832213088815
5014447304220
3258075465137
4752661913013
414236...

result:

ok 3000000 lines

Test #2:

score: 0
Accepted
time: 2574ms
memory: 418564kb

input:

2800 3000000
965 1667 1992 7410928
1503 1052 1343 380539884
2975 153 2372 829879946
948 1591 1587 946223894
1827 523 2553 838896284
2912 1657 1483 906521660
2504 1710 344 605382660
1579 477 2639 942543810
2742 2155 256 299044504
474 1033 1507 6351536
564 2718 2276 492875414
2367 1693 10 99409474
283...

output:

4296672484275
2838067388343
3576685043620
3788366437246
3775266906919
3331817010229
5333610137416
3157293061917
5181405226683
4275067257588
5520113850938
5039754376141
3550524721862
4678938214541
4751105818446
3271622439448
3109348772197
5048566999780
4337978371147
4526301102774
2954016136820
295356...

result:

ok 3000000 lines

Test #3:

score: 0
Accepted
time: 876ms
memory: 189100kb

input:

2800 3000000
980 131 25 595888862
439 76 88 298745372
555 587 278 108892094
138 1178 165 431872072
225 106 239 950180368
87 1120 1111 104640476
171 1222 1169 367119884
71 1332 1177 172311268
496 620 531 393898228
103 1304 64 522772526
53 779 726 479320332
810 480 319 324127584
534 865 539 211550766
...

output:

0
231749998146
696249997002
0
554749995562
0
0
0
1359213584970
1914511980179
654499997381
1813037811025
602749995178
749499994894
0
749499995159
623999995008
435999998255
348749998604
250499997996
749499995024
749499995016
657374997002
1948599682464
1764515357602
0
930290619342
632624997002
74949999...

result:

ok 3000000 lines

Test #4:

score: 0
Accepted
time: 484ms
memory: 80596kb

input:

2800 3000000
1523 1370 1471 6090
2817 76 177 999999698
675 2218 2319 2698
672 2221 2322 2686
1174 1719 1820 4694
755 2138 2239 3018
317 2576 2677 1266
166 2727 2828 662
865 2028 2129 3458
993 1900 2001 3970
743 2150 2251 2970
2488 405 506 999998382
1340 1553 1654 5358
2398 495 596 999998022
935 1958...

output:

0
99999618805
100999999798
0
94999273840
100999999798
100999999798
100999999798
100999999798
0
100999999798
0
100999999798
99999952305
100999999798
100999999798
0
100999999798
100999999798
0
100999999798
100999999798
0
0
0
99999750895
100999999798
100999999798
100999999798
100999999798
99999284984
1...

result:

ok 3000000 lines

Test #5:

score: 0
Accepted
time: 1592ms
memory: 342232kb

input:

2800 3000000
3000 92 3000 356984936
3000 2876 1 833329450
3000 2186 1 577293044
3000 1608 1 792543756
3000 2091 1 800982380
3000 1910 1 8574654
3000 937 3000 933102166
3000 514 3000 278657758
3000 2873 1 401730486
3000 77 3000 928267494
3000 2598 1 234726890
3000 1034 3000 140197662
3000 968 3000 40...

output:

2960248819460
2960248819460
2960248819460
2960248819460
2960248819460
2960248819460
2960248819460
2960248819460
2960248819460
2960248819460
2960248819460
2960248819460
2960248819460
2960248819460
2960248819460
2960248819460
2960248819460
2960248819460
2960248819460
2960248819460
2960248819460
296024...

result:

ok 3000000 lines

Subtask #2:

score: 7
Accepted

Test #6:

score: 7
Accepted
time: 1521ms
memory: 309908kb

input:

2800 1
115680916 186653907 216867352 95901618
454264769 375013472 304801187 474587118
625934493 597189381 75363688 656578612
86421753 459154293 114622112 552696826
541134745 82557014 797632881 87483584
220037532 326160496 144521513 247107338
162000586 540621649 94052034 808370136
482531445 326552822...

output:

1610674590390004342

result:

ok single line: '1610674590390004342'

Test #7:

score: 0
Accepted
time: 1474ms
memory: 307204kb

input:

2800 1
510527057 576280573 217493521 32571370
921890390 573647378 571386803 974493416
568595811 700437738 768668768 316335490
636988803 956850274 219937417 909584100
245868984 698920096 592253071 448726230
922956751 102636858 471119343 194999732
219160668 528355843 259745630 857306298
562428977 7477...

output:

863956522476108956

result:

ok single line: '863956522476108956'

Test #8:

score: 0
Accepted
time: 1398ms
memory: 309728kb

input:

2800 1
120870164 310507070 121316156 310597488
119471021 126220603 239381707 734251214
117555508 297656017 288292003 168954844
263658422 120701860 132054482 628141948
362840938 71972976 24130636 711728140
75017776 211353516 5468516 716638338
73124273 320181175 139430963 389120116
44043293 130041980 ...

output:

249999998500000002

result:

ok single line: '249999998500000002'

Test #9:

score: 0
Accepted
time: 27ms
memory: 8188kb

input:

2800 1
250002716 77 250000078 999999694
250001683 1110 250001111 999995562
250002756 37 250000038 999999854
250001939 854 250000855 999996586
250002142 651 250000652 999997398
250002339 454 250000455 999998186
250001827 966 250000967 999996138
1196 250001597 500001598 4782
250002720 73 250000074 999...

output:

249999999500000002

result:

ok single line: '249999999500000002'

Test #10:

score: 0
Accepted
time: 1261ms
memory: 325316kb

input:

2800 1
822733 1139659 3102870 3622
655202 2614732 653800 2
351402 2310498 350000 2
1811602 3772784 1810200 2
336309 1626739 3589294 2310
391555 1571401 3534048 2494
1652002 3612956 1650600 2
395305 1567645 3530298 2506
263202 2222172 261800 2
390602 2349754 389200 2
613545 1349095 3312058 3126
49243...

output:

10995586002

result:

ok single line: '10995586002'

Test #11:

score: 0
Accepted
time: 1170ms
memory: 234644kb

input:

2800 1
813292 169779 661610 500002260
641902 1326077 1816500 2
833974 1816539 1324672 500002332
530602 527905 37800 2
744102 742015 251300 2
683162 300169 791740 500001740
637702 635311 144900 2
966158 1948931 1456856 500002748
835802 1131623 1622600 2
861344 121645 613558 500002424
827402 825553 33...

output:

246050875908804

result:

ok single line: '246050875908804'

Test #12:

score: 0
Accepted
time: 1130ms
memory: 243712kb

input:

2798 1
1 725 999999325 1000000000
1 729 999999329 1000000000
1 876 999999476 1000000000
1 999999416 816 1000000000
1 999999728 1128 1000000000
1 813 999999413 1000000000
1 999999327 727 1000000000
1 999999784 1184 1000000000
1 1129 999999729 1000000000
1 999999048 448 1000000000
1 485 999999085 1000...

output:

499999300000000000

result:

ok single line: '499999300000000000'

Subtask #3:

score: 15
Accepted

Test #13:

score: 15
Accepted
time: 1709ms
memory: 321156kb

input:

2800 3000
770603717 777601720 723319989 302673280
902835270 877924569 257679946 792554214
666961330 943914492 527105101 4933224
115173395 748219976 809825809 912972096
196936214 104048860 317670549 297118746
847424736 113348527 932963421 461743858
395308130 647500321 476878619 229851232
790531516 13...

output:

1472670293891572885
1297889177572317702
868358725431894191
1213713470691107417
886066698158024009
1008597740690930875
1241308628842217330
1503381233274921030
840395569675363359
1642855331011439686
955774685070284799
998044703115840206
1266516350057055283
1205059233121662834
1213475337571546024
87108...

result:

ok 3000 lines

Test #14:

score: 0
Accepted
time: 1691ms
memory: 318752kb

input:

2800 3000
186223747 269459526 896520331 779478620
190947509 946573400 710237968 732910768
125908859 426660569 78629307 468933216
284195848 592896107 522782082 564555586
354226783 653000153 364213828 346754082
225919629 886401096 948984031 696675706
429779611 883690239 706571787 999011096
336618753 7...

output:

1205936044798304532
1769297185507360507
1583442111693811646
1722361900576469889
1713485327734664383
961417298095001714
1471056022403887403
1255943244280896799
1712526118585192652
1216925976657931360
1733976704350696599
990685738106340959
1179172273024947185
1018201761066468395
1336555711083400084
17...

result:

ok 3000 lines

Test #15:

score: 0
Accepted
time: 1531ms
memory: 310444kb

input:

2800 3000
221857059 274180815 114763539 889094568
278682715 25426472 46195877 685756778
53654209 258028177 169258615 904356432
402828637 74077471 62603268 954712714
84565853 33729035 13526474 823309476
88610989 231450599 145087788 587411122
76292977 21576499 37867044 949816400
184208489 103219372 73...

output:

434386282759246745
240551232825590122
0
580560723048235182
514788261762500009
664399680507027171
237608424875000002
0
222625667968994642
249999997760475935
184999921010000312
601132560505559929
450344174725508382
176631108293475563
0
70745896434032824
249999998011029862
0
240098756579209932
10250363...

result:

ok 3000 lines

Test #16:

score: 0
Accepted
time: 28ms
memory: 8536kb

input:

2800 3000
306 250002487 500002488 1222
250002134 659 250000660 999997366
250002223 570 250000571 999997722
1064 250001729 500001730 4254
85 250002708 500002709 338
250002454 339 250000340 999998646
1770 250001023 500001024 7078
250002759 34 250000035 999999866
250002786 7 250000008 999999974
408 250...

output:

0
249999999500000002
249999999500000002
249999999500000002
249999999500000002
249999999500000002
249999999500000002
249999999500000002
249999999500000002
0
249999999500000002
249999999500000002
249999999500000002
249999999500000002
0
249999999500000002
249999999500000002
249999999500000002
249999999...

result:

ok 3000 lines

Test #17:

score: 0
Accepted
time: 1332ms
memory: 331420kb

input:

2800 3000
974013 988219 2951590 3942
994002 2954016 992600 2
1093783 868331 2831820 4178
1314973 646939 2610630 4582
603402 2562858 602000 2
527802 2487150 526400 2
7495 1956571 3918108 274
1692602 3653614 1691200 2
446602 2405834 445200 2
724453 1238051 3201150 3398
1271202 3231612 1269800 2
183820...

output:

10074548214
8976742326
4901511398
1549638272
4529222460
7149123824
200637576
9690089132
3574752804
3778762220
2725832852
6359182262
7628490198
10081911032
7345290474
1746319670
4336074362
1141533252
8444644910
9463607190
8239981806
3094371974
1996064694
7376475006
6695067716
2647454472
6852043260
53...

result:

ok 3000 lines

Test #18:

score: 0
Accepted
time: 1267ms
memory: 237172kb

input:

2800 3000
693702 691471 200900 2
820402 1147067 1638000 2
665312 1647539 1156010 500001656
809902 808003 317100 2
764402 1203227 1694000 2
554264 1536155 1044962 500000984
709262 274011 765640 500001856
921902 1045277 1536500 2
661192 1643409 1151890 500001636
978602 977185 485800 2
941502 1025621 1...

output:

164271918704682
41543732529052
198632110826970
126990710590802
146583320298748
69840391081928
8542548153348
9794054770936
83506967517500
19900111328850
94916530807810
236776324255752
89827502814586
43692744441748
181184013180138
11666565737070
202555132691216
75006419433552
229075781168222
188198052...

result:

ok 3000 lines

Test #19:

score: 0
Accepted
time: 1221ms
memory: 245208kb

input:

2800 3000
8800 687 4200 828039160
8800 1561 4200 811364330
8800 3153 1400 268987046
8800 3013 1400 953842310
8800 4555 1400 672760128
8800 4959 1400 23326892
8800 2455 4200 805036824
8800 5101 1400 10756196
8800 773 4200 686431250
8800 1343 4200 536657146
8800 1299 4200 128881882
8800 3209 1400 2576...

output:

4167785060266
4167785060266
4167785060266
4167785060266
4167785060266
4167785060266
4167785060266
4167785060266
4167785060266
4167785060266
4167785060266
4167785060266
4167785060266
4167785060266
4167785060266
4167785060266
4167785060266
4167785060266
4167785060266
4167785060266
4167785060266
416778...

result:

ok 3000 lines

Subtask #4:

score: 20
Accepted

Test #20:

score: 20
Accepted
time: 1754ms
memory: 409932kb

input:

2800 40000
586592081 142194416 985994983 486410466
903096905 351511863 950630903 603827692
351769596 263181509 959278118 873759602
396075726 961889997 961773648 127530762
616690137 822387827 329819360 582660688
714379329 9528551 317948579 776234508
969071737 428895985 13505331 627840848
989682531 72...

output:

1658282800397078394
1256566728891487734
1633804920809328392
1651548702881643041
1489582895805491463
987830361328678705
1015374867451859509
972577823077670310
1119965331007445483
818616342929481610
1511180629635942508
1069316553863059195
1522848191875439390
915417125488405240
1667180738972183305
1101...

result:

ok 40000 lines

Test #21:

score: 0
Accepted
time: 1680ms
memory: 408728kb

input:

2800 40000
521486638 27918622 630919313 324507956
511846801 24365959 467359764 869568458
177880392 838604596 422787535 503245442
970056169 587245308 598091820 785699564
968506975 753669242 780975256 137637470
512375971 116599061 887192796 958152186
498690255 233286790 405345690 41072762
426646851 30...

output:

1155371155941134397
1732078885859182690
864158797707083569
1575008565915713692
1034276439927241231
1174618997120410579
1405317085285456482
1384195872158671410
1754834359276113270
1563254096410827451
1542618192231327104
1433718256905042742
1554231510480193598
783525715039988619
1500339000638455360
17...

result:

ok 40000 lines

Test #22:

score: 0
Accepted
time: 1608ms
memory: 332880kb

input:

2800 40000
27431592 164668535 307370605 250703816
111907820 363700276 251652460 89473420
75754721 196818197 109090086 760617582
219294817 240346916 166483539 193552164
219424536 64472434 54371270 123810328
168412251 245764218 150197027 119991352
204010714 126004085 191820691 902576590
168679978 1704...

output:

201196790625000002
239049523337603798
236508574375000002
0
0
519474697688896250
0
249999998313039586
0
0
0
119703412292372694
141033681685865270
0
218763333249893320
0
116430401068556784
215860278886558880
136332351704670590
173132432364940530
0
249999997927537929
197888392500000002
5557498777770004...

result:

ok 40000 lines

Test #23:

score: 0
Accepted
time: 37ms
memory: 6716kb

input:

2800 40000
903 250001890 500001891 3610
250002673 120 250000121 999999522
250002588 205 250000206 999999182
747 250002046 500002047 2986
692 250002101 500002102 2766
781 250002012 500002013 3122
1031 250001762 500001763 4122
1529 250001264 500001265 6114
735 250002058 500002059 2938
1428 250001365 5...

output:

249999999123020551
0
0
249999999500000002
250000000499999998
212028430375868447
0
0
0
0
0
0
0
249999999500000002
249999999061099366
0
0
0
249999999179690070
0
0
0
249999999318060552
0
0
0
0
162931224373112224
0
249999999063607001
0
0
249999999500000002
0
0
0
233711170893841408
0
0
168597896587010160...

result:

ok 40000 lines

Test #24:

score: 0
Accepted
time: 1351ms
memory: 333364kb

input:

2800 40000
1167602 3127864 1166200 2
1142359 819709 2783244 4270
1817202 3778392 1815800 2
1177402 3137678 1176000 2
1240459 721519 2685144 4450
981913 980311 2943690 3958
9609 1954429 3915994 330
662959 1299619 3262644 3250
59685 1904041 3865918 954
1281002 3241426 1279600 2
51802 2010470 50400 2
1...

output:

2937666866
9015575828
3754280430
10929327176
9746503130
9746216558
10811290158
10379958840
2984651006
909419336
6936989018
1074374150
2231517546
10364277240
6524357220
1549850120
6515656466
3219680042
1360947620
4760211770
1192043880
399112166
273361418
529419680
8623499688
10389386378
9996829478
45...

result:

ok 40000 lines

Test #25:

score: 0
Accepted
time: 1236ms
memory: 239232kb

input:

2800 40000
494258 1475711 984956 500000108
735702 1232009 1722700 2
794502 1173041 1663900 2
940394 1923129 1431092 500002672
591158 1573181 1081856 500001248
758102 756055 265300 2
652304 331101 822598 500001592
576102 1392065 1882300 2
931002 1036151 1527400 2
956902 1010177 1501500 2
550202 54756...

output:

123215689223080
225906263482538
6198534757934
223998753420918
95973036710478
149887338293326
159927394812996
169525448089582
58395326696090
70005891540694
32459681661492
210885679372846
33257685988108
84434972167524
140974788938226
173847472149630
23074629059054
79046442245680
223959252374018
963020...

result:

ok 40000 lines

Test #26:

score: 0
Accepted
time: 1250ms
memory: 245072kb

input:

2800 40000
82800 1387 4200 523637894
82800 2033 4200 31661758
82800 2637 4200 605003780
82800 2425 4200 826176510
82800 3155 1400 186200888
82800 2383 4200 405440398
82800 3159 1400 28545344
82800 2993 1400 486184222
82800 3691 1400 794961364
82800 1459 4200 449556146
82800 5353 1400 839967926
82800...

output:

4130305700014
4130305700014
4130305700014
4130305700014
4130305700014
4130305700014
4130305700014
4130305700014
4130305700014
4130305700014
4130305700014
4130305700014
4130305700014
4130305700014
4130305700014
4130305700014
4130305700014
4130305700014
4130305700014
4130305700014
4130305700014
413030...

result:

ok 40000 lines

Subtask #5:

score: 52
Accepted

Test #27:

score: 52
Accepted
time: 3631ms
memory: 717244kb

input:

2800 3000000
659809898 379150776 345964751 894447796
183554499 765956940 604952471 91923650
648956547 195844980 722948102 771810000
495138321 236852229 174047728 194808998
92856444 709141070 796693235 97013230
742480198 381926767 976036847 348816284
572838818 949680013 542296028 154082812
517449837 ...

output:

1644297359906174973
1010640606604936755
1105558328952482934
1161972541804989010
1212630603046911852
965514030926340898
1631543898920714866
920657300896064408
1432190859149912616
1549196350070033135
1464934763422247874
1275431129898811913
1700970628244613588
1199920581196050967
1688183187656778496
17...

result:

ok 3000000 lines

Test #28:

score: 0
Accepted
time: 3767ms
memory: 711664kb

input:

2800 3000000
306424485 485594906 369043958 636343198
818907123 1239514 49799509 124544700
317852069 946358422 65220608 430881984
287161714 407868599 378145510 124496440
997185365 181216396 653298474 490419638
376743995 761237267 902600621 705719956
403969788 88193314 749127159 340682384
162800429 84...

output:

1154735778562642673
1392878043031209489
1305843139820933005
1722396404428536831
870240299362874348
1044277168369605173
1280034587029512919
1566727972979013033
1096806434685758664
1665732315749423124
1571698706446789741
1185856907535916750
1356018765010282671
1078352481868195225
1495296910895645553
8...

result:

ok 3000000 lines

Test #29:

score: 0
Accepted
time: 2630ms
memory: 677412kb

input:

2800 3000000
338812070 117768697 96462256 9217102
84465206 85929445 88566760 949171476
223997267 92397691 168353643 888365222
166496324 87260276 164960185 542016216
197412939 226744491 178700713 564033766
98585358 307057096 35903678 979574502
13727582 179134879 320969263 368681454
170470338 32253680...

output:

0
194046657223813367
100340153947278762
234538899623688788
0
111117179111062560
0
216914078375000002
106972827322108688
237941111250000002
0
0
157503565739971464
223075241715398052
221344178750000002
0
219619128493046958
232416935640664500
249999997660486090
0
223043432625000002
511262736028116267
2...

result:

ok 3000000 lines

Test #30:

score: 0
Accepted
time: 394ms
memory: 52576kb

input:

2800 3000000
717 250002076 500002077 2866
250002075 718 250000719 999997130
1359 250001434 500001435 5434
1602 250001191 500001192 6406
1499 250001294 500001295 5994
1887 250000906 500000907 7546
250002523 270 250000271 999998922
1799 250000994 500000995 7194
250002669 124 250000125 999999506
1803 2...

output:

0
0
0
0
0
0
245422641530556863
0
249999999133412271
0
135920570531463248
0
0
249999999189148222
249999999041853746
0
0
0
0
0
0
0
0
223107989347035482
0
0
0
0
0
249999999255313087
0
207479516769331995
0
0
0
0
0
0
0
0
0
0
0
214063353986884154
0
0
0
0
167528904358540436
201730704702679275
0
0
249999999...

result:

ok 3000000 lines

Test #31:

score: 0
Accepted
time: 1924ms
memory: 408528kb

input:

2800 1960001
424653 1538251 3500950 2598
50983 1912781 3874620 878
116035 1847495 3809568 1346
513802 2473130 512400 2
9445 1954595 3916158 326
1925002 3886346 1923600 2
1380402 3340968 1379000 2
764059 1198399 3161544 3490
754602 2714274 753200 2
1619515 342145 2306088 5086
166602 2125434 165200 2
...

output:

9786911768
9425720844
6060707270
9856482714
8199638456
545231628
1519970276
9331318928
1471141472
7094782394
7691606762
2529741870
6850827756
8042817464
6170654142
2827830722
477241182
3604159196
5055554126
3740370734
717652532
6915921524
2875711814
2406439514
9541113782
9402178770
10670122646
93841...

result:

ok 1960001 lines

Test #32:

score: 0
Accepted
time: 2324ms
memory: 362296kb

input:

2800 3000000
676202 1291679 1782200 2
954802 1012283 1503600 2
534104 449695 940798 500000804
837202 1130219 1621200 2
508754 1490399 999452 500000492
804308 1786821 1295006 500002228
499822 484221 975080 500000316
653802 651457 161000 2
529202 526501 36400 2
723802 721657 231000 2
510302 507547 175...

output:

135093755756864
187487548431708
99087554180202
16790093898392
177941995146424
94527528686576
72760407037512
3493519536534
167986439889014
94461028463934
222414743923564
107209099525070
239632340113352
163822416447686
101014065494692
39946723381550
220785734633886
229367782970268
130716730966914
2266...

result:

ok 3000000 lines

Test #33:

score: 0
Accepted
time: 1598ms
memory: 345324kb

input:

2800 3000000
6002800 581 4200 571849490
6002800 3403 1400 677516642
6002800 2787 4200 412274694
6002800 955 4200 773823150
6002800 4933 1400 600388780
6002800 4777 1400 348714894
6002800 1629 4200 557789034
6002800 4485 1400 555730416
6002800 4547 1400 820330450
6002800 863 4200 981361996
6002800 14...

output:

4152366915470
4152366915470
4152366915470
4152366915470
4152366915470
4152366915470
4152366915470
4152366915470
4152366915470
4152366915470
4152366915470
4152366915470
4152366915470
4152366915470
4152366915470
4152366915470
4152366915470
4152366915470
4152366915470
4152366915470
4152366915470
415236...

result:

ok 3000000 lines

Extra Test:

score: 0
Extra Test Passed