QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#501923#8641. Ski 2green_gold_dog86 346ms433808kbC++202.6kb2024-08-02 23:58:052024-08-02 23:58:06

Judging History

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

  • [2024-08-02 23:58:06]
  • 评测
  • 测评结果:86
  • 用时:346ms
  • 内存:433808kb
  • [2024-08-02 23:58:05]
  • 提交

answer

//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,sse,sse2,sse3,ssse3,sse4,abm,popcnt,mmx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef double db;
typedef long double ldb;
typedef complex<double> cd;

constexpr ll INF64 = 9'000'000'000'000'000'000, INF32 = 2'000'000'000, MOD = 1'000'000'007;
constexpr db PI = acos(-1);
constexpr bool IS_FILE = false, IS_TEST_CASES = false;

random_device rd;
mt19937 rnd32(rd());
mt19937_64 rnd64(rd());

template<typename T>
bool assign_max(T& a, T b) {
	if (b > a) {
		a = b;
		return true;
	}
	return false;
}

template<typename T>
bool assign_min(T& a, T b) {
	if (b < a) {
		a = b;
		return true;
	}
	return false;
}

template<typename T>
T square(T a) {
	return a * a;
}

template<>
struct std::hash<pair<ll, ll>> {
	ll operator() (pair<ll, ll> p) const {
		return ((__int128)p.first * MOD + p.second) % INF64;
	}
};

void solve() {
	ll n, k;
	cin >> n >> k;
	map<ll, vector<ll>> all;
	for (ll i = 0; i < n; i++) {
		ll x, y;
		cin >> x >> y;
		all[x].push_back(y);
	}
	ll x = all.begin()->first;
	sort(all[x].begin(), all[x].end());
	ll cost = all[x][0];
	ll ans = (all[x].size() - 1) * k;
	for (ll i = 1; i < all[x].size(); i++) {
		all[x + 1].push_back(all[x][i]);
	}
	all.erase(x);
	ll nc = 0;
	vector<ll> aa;
	x++;
	while (nc >= 0 || all.lower_bound(x) != all.end()) {
		aa.push_back(x);
		nc += all[x].size();
		if (nc < 0) {
			ll y = all.lower_bound(x)->first;
			nc = 0;
			if (x == y) {
				y++;
			}
			x = y;
		} else {
			x++;
		}
		nc--;
	}
	aa.push_back(x);
	vector<vector<vector<ll>>> dp(aa.size(), vector<vector<ll>>(n + 1, vector<ll>(n + 1, INF64)));
	dp[0][0][1] = ans;
	ll mcp = 0, msz = 1;
	for (ll i = 0; i + 1 < aa.size(); i++) {
		sort(all[aa[i]].begin(), all[aa[i]].end());
		for (ll cp = 0; cp <= mcp; cp++) {
			for (ll sz = 1; sz <= msz; sz++) {
				if (dp[i][cp][sz] == INF64) {
					continue;
				}
				ll ce = cp + all[aa[i]].size() - sz;
				for (ll addsz = 0; addsz <= max(0ll, ce); addsz++) {
					assign_min(dp[i + 1][max(0ll, ce - addsz)][sz + addsz], dp[i][cp][sz] + cost * addsz + max(0ll, ce - addsz) * k);
				}
			}
		}
		if (!all[aa[i]].empty()) {
			assign_min(cost, all[aa[i]][0]);
		}
		msz += all[aa[i]].size();
		mcp += all[aa[i]].size();
		mcp--;
		assign_max(mcp, 0ll);
	}
	ans = INF64;
	for (ll i = 0; i <= n; i++) {
		assign_min(ans, dp.back()[0][i]);
	}
	cout << ans << '\n';
}

int main() {
	if (IS_FILE) {
		freopen("", "r", stdin);
		freopen("", "w", stdout);
	}
    	ios_base::sync_with_stdio(false);
    	cin.tie(0);
    	cout.tie(0);
	ll t = 1;
	if (IS_TEST_CASES) {
		cin >> t;
	}
	for (ll i = 0; i < t; i++) {
		solve();
	}
}

詳細信息

Subtask #1:

score: 5
Accepted

Test #1:

score: 5
Accepted
time: 24ms
memory: 224788kb

input:

300 987761245
249 97
279 38
52 53
190 2
294 46
170 93
260 70
273 6
49 4
32 71
188 28
212 10
253 86
187 46
167 27
32 75
226 90
86 17
172 24
129 70
291 78
189 98
97 98
256 19
228 36
240 86
240 63
269 21
81 81
41 25
155 49
279 12
176 49
136 25
260 95
271 90
202 79
299 36
79 53
297 59
46 92
202 19
125 3...

output:

144

result:

ok single line: '144'

Test #2:

score: 5
Accepted
time: 12ms
memory: 226992kb

input:

300 451766134
225 3
78 77
144 26
211 37
119 39
126 65
7 47
53 7
121 37
52 60
212 24
168 60
212 42
104 45
218 4
146 42
234 25
43 83
126 67
128 61
125 80
87 62
113 8
71 28
148 80
175 34
126 77
295 91
35 62
265 31
35 29
108 8
195 34
85 59
250 41
78 62
242 17
178 80
34 15
187 60
94 34
50 25
144 29
10 8
...

output:

103

result:

ok single line: '103'

Test #3:

score: 5
Accepted
time: 23ms
memory: 224796kb

input:

300 584296612
252 63
248 8
136 92
181 38
206 77
229 21
196 84
7 86
187 29
170 42
195 10
148 100
279 2
113 65
22 18
148 68
11 14
187 72
133 59
205 7
155 95
251 76
300 18
265 19
76 59
59 76
86 7
73 84
101 49
19 47
25 70
24 44
29 75
112 77
128 27
28 27
198 29
148 56
128 89
218 26
177 13
117 84
25 91
0 ...

output:

1168593404

result:

ok single line: '1168593404'

Test #4:

score: 5
Accepted
time: 24ms
memory: 225004kb

input:

300 542226210
235 86
10 24
160 95
40 31
293 60
285 77
285 97
24 83
26 70
254 50
136 68
112 23
84 28
236 41
101 49
70 94
282 6
231 57
199 51
146 39
55 54
192 47
192 66
72 74
186 96
136 42
72 13
282 18
296 53
127 46
16 75
241 84
146 52
241 62
231 5
143 46
40 35
105 69
126 31
252 3
101 16
154 33
30 100...

output:

125

result:

ok single line: '125'

Test #5:

score: 5
Accepted
time: 28ms
memory: 231944kb

input:

300 851059749
59 76
266 2
7 58
202 53
214 58
256 30
99 28
224 16
64 80
150 93
12 14
278 15
196 7
259 97
13 27
256 100
66 90
257 26
85 44
49 64
171 63
266 37
95 44
123 75
203 41
261 89
81 30
65 51
64 42
66 45
108 10
198 45
128 86
234 49
199 77
65 37
234 52
246 8
198 12
50 3
181 71
218 83
66 85
261 73...

output:

851059869

result:

ok single line: '851059869'

Test #6:

score: 5
Accepted
time: 23ms
memory: 224196kb

input:

300 947403587
92 86
43 91
295 85
105 15
236 78
295 66
11 82
72 54
69 76
145 17
224 66
19 35
249 75
21 92
99 85
38 61
222 81
145 68
14 60
21 23
38 97
133 63
257 6
139 64
295 34
133 80
157 29
57 33
38 9
155 31
102 77
191 98
201 87
255 85
203 38
242 54
38 78
242 59
159 81
26 56
43 82
102 83
14 94
36 87...

output:

947404177

result:

ok single line: '947404177'

Test #7:

score: 5
Accepted
time: 260ms
memory: 219856kb

input:

300 363080349
19 96
23 83
20 86
22 86
7 93
12 100
21 79
14 92
15 90
19 91
23 96
16 89
20 84
8 100
22 79
21 94
20 85
19 88
11 100
22 90
22 80
2 99
23 89
21 84
23 80
8 96
9 96
23 88
17 93
16 84
11 95
22 90
18 86
11 92
19 81
18 88
9 92
12 97
4 98
17 89
23 95
5 99
10 93
18 89
10 97
16 91
8 97
16 85
20 8...

output:

363082396

result:

ok single line: '363082396'

Test #8:

score: 5
Accepted
time: 300ms
memory: 219796kb

input:

300 1000000000
300 57
300 24
300 40
300 45
300 68
300 38
300 94
300 79
300 39
300 87
300 98
300 79
300 63
300 56
300 97
300 63
300 52
300 61
300 83
300 35
300 19
300 38
300 12
300 9
300 87
300 3
300 92
300 54
300 5
300 37
300 43
300 11
300 25
300 87
300 70
300 65
300 58
300 57
300 70
300 87
300 67
3...

output:

299000000298

result:

ok single line: '299000000298'

Subtask #2:

score: 12
Accepted

Test #9:

score: 12
Accepted
time: 330ms
memory: 219780kb

input:

300 1
0 6596366
1 195480684
2 39457151
1 832234727
1 462764495
2 81049898
0 487070027
1 430671894
2 721333033
1 615885993
1 842070560
1 592116125
2 840818824
0 544935711
2 333187430
2 467111553
0 416912849
2 159079860
0 478546939
0 593053374
0 876528192
2 9215174
1 93255151
2 120891934
0 10339332
2 ...

output:

44543

result:

ok single line: '44543'

Test #10:

score: 12
Accepted
time: 307ms
memory: 219808kb

input:

300 1060203
0 1286878
1 960668502
2 190866228
1 195306795
1 233497287
0 343641186
0 693228127
0 67978764
2 598546069
0 751890541
0 37754998
0 305348452
1 266631431
1 844903768
1 560113131
2 47250552
0 594767495
2 809926081
0 586661105
0 366656127
0 589306393
2 416896948
2 89253046
1 363341342
0 9491...

output:

373039535

result:

ok single line: '373039535'

Test #11:

score: 12
Accepted
time: 298ms
memory: 219804kb

input:

300 1011700
0 4143879
5 61178231
1 214955252
5 577924292
3 532426729
4 862464334
4 215922747
1 602163591
2 90390184
4 709933135
1 948890772
3 784747556
2 261263945
4 784527448
3 989184114
5 465210434
3 83935742
5 876450661
3 626127035
1 699569645
1 5830291
4 974711739
0 542998610
3 604346813
1 14345...

output:

365657793

result:

ok single line: '365657793'

Test #12:

score: 12
Accepted
time: 314ms
memory: 219836kb

input:

300 2629882
0 7876717
1 380548027
4 210300855
3 804812637
0 795433451
0 696287735
1 251831535
2 510880579
5 328652705
0 850216531
5 609349591
3 66131892
5 355383071
2 846765095
2 127222407
1 933995931
0 609083290
4 506229752
1 922802380
3 277035017
2 693421958
0 339580672
4 296433175
1 933653265
2 5...

output:

732780332

result:

ok single line: '732780332'

Test #13:

score: 12
Accepted
time: 122ms
memory: 219788kb

input:

300 2161
0 4686752
8 629699716
36 412556162
10 196116733
93 237242586
45 458684505
60 125966325
2 855656971
76 750982211
88 543425907
38 355258329
92 448453464
26 608377947
93 18561617
69 644272241
23 178136181
48 306908918
32 962694105
79 683443776
28 623663382
100 501582180
92 578581062
26 8341942...

output:

10667943

result:

ok single line: '10667943'

Test #14:

score: 12
Accepted
time: 115ms
memory: 219804kb

input:

300 1264601
0 2244378
70 999535496
70 770638615
43 175588958
7 679253897
72 966146892
8 723807777
30 214248412
86 304229971
69 177589825
48 546447871
66 385401179
92 977036346
39 868966348
81 533340807
23 441268090
51 803400831
84 17907592
22 67033263
60 751134225
1 131600198
14 437904793
79 3453315...

output:

18239848

result:

ok single line: '18239848'

Test #15:

score: 12
Accepted
time: 31ms
memory: 224012kb

input:

300 425400
0 1915855
18 418792787
218 647548770
186 171684693
20 829774979
38 495244240
273 322971719
51 872137770
279 602534746
37 558726564
180 812007613
102 106188773
37 691630980
172 664413269
154 456050691
155 277923631
218 685494540
56 834990956
128 808406942
73 966781691
154 610439249
198 103...

output:

5958710

result:

ok single line: '5958710'

Test #16:

score: 12
Accepted
time: 31ms
memory: 223224kb

input:

300 1158451
1 12714371
194 740204971
274 273192348
10 233690292
30 152192819
241 350005285
140 376261817
105 246687825
290 515238843
15 563646519
47 417246070
244 220045148
155 413470747
204 711463900
167 810376102
185 470107777
271 261463098
232 228256857
108 164983349
59 752563934
109 787862089
11...

output:

31220997

result:

ok single line: '31220997'

Test #17:

score: 12
Accepted
time: 276ms
memory: 219792kb

input:

300 232014275
0 1335577
20 923253862
10 861996110
2 534287257
4 97575908
6 703656009
20 176840984
0 995189842
4 847450828
10 532473518
8 638980368
20 956596084
6 790434470
4 773069953
12 772814387
14 893619615
8 394660502
16 367410607
20 210732209
2 338176881
20 862071228
10 159569938
4 345386924
14...

output:

5617758949

result:

ok single line: '5617758949'

Test #18:

score: 12
Accepted
time: 210ms
memory: 219772kb

input:

300 7917929
2 23753787
4 881012995
4 843565653
6 243395540
6 332308712
6 731673552
8 768571347
8 667663560
8 999384285
8 605635849
10 672916805
10 549596745
10 608973816
10 969769288
10 123642168
12 924486873
12 714943281
12 322453474
12 611226720
12 70245389
12 249196857
14 43704099
14 400483309
14...

output:

522583314

result:

ok single line: '522583314'

Test #19:

score: 12
Accepted
time: 214ms
memory: 219992kb

input:

300 5712244
2 85683660
4 531574076
4 143856895
6 500019170
6 569021851
6 845915493
8 484912884
8 110335721
8 377454454
8 970107075
10 668551087
10 573840833
10 602084189
10 840330670
10 393762627
12 676568255
12 481846266
12 529475072
12 307726263
12 960271047
12 725995830
14 348984197
14 214766767
...

output:

1388075292

result:

ok single line: '1388075292'

Subtask #3:

score: 9
Accepted

Test #20:

score: 9
Accepted
time: 0ms
memory: 3820kb

input:

10 849097758
4 937762392
10 817247459
0 440668594
1 912982987
7 663812156
7 594886472
0 837105766
2 737473115
3 649275922
10 873042888

output:

1289766352

result:

ok single line: '1289766352'

Test #21:

score: 9
Accepted
time: 0ms
memory: 3820kb

input:

10 9998
5 878445115
0 949971639
4 896709623
3 782518625
0 763551803
2 795919483
10 820305225
7 955019709
0 988957902
6 794013355

output:

89982

result:

ok single line: '89982'

Test #22:

score: 9
Accepted
time: 0ms
memory: 3864kb

input:

10 313931642
1 752682337
6 864853209
7 172291208
3 849996643
9 462903663
3 806832309
7 415016851
7 200488544
2 936575125
4 772486850

output:

1066613979

result:

ok single line: '1066613979'

Test #23:

score: 9
Accepted
time: 0ms
memory: 3648kb

input:

10 374
3 962058719
9 752701033
9 645570821
7 985449153
7 578273422
3 804266379
5 854354117
4 993866589
9 911208632
4 975880747

output:

5610

result:

ok single line: '5610'

Test #24:

score: 9
Accepted
time: 0ms
memory: 3856kb

input:

10 324770512
10 375908339
1 411213202
4 392519015
8 901521995
5 421608634
9 705664450
3 592078552
6 633681433
0 534389104
10 683380690

output:

324770512

result:

ok single line: '324770512'

Test #25:

score: 9
Accepted
time: 0ms
memory: 3652kb

input:

10 108923
10 120608144
6 991122545
10 591398529
6 777899046
1 904193758
9 944103839
7 642544838
4 688262357
1 953425951
10 190058178

output:

653538

result:

ok single line: '653538'

Test #26:

score: 9
Accepted
time: 0ms
memory: 3568kb

input:

10 932546022
9 38744232
1 995739974
2 998741663
6 847774949
2 996519521
5 866539522
7 526895946
10 8709873
4 996793074
6 844393176

output:

995739974

result:

ok single line: '995739974'

Test #27:

score: 9
Accepted
time: 0ms
memory: 3656kb

input:

10 11953563
0 994878622
3 906206994
1 915019718
1 864107053
0 999397042
6 581277066
3 676038157
10 83264360
0 996754561
7 229761931

output:

179303445

result:

ok single line: '179303445'

Test #28:

score: 9
Accepted
time: 0ms
memory: 3636kb

input:

10 714566765
6 565233644
1 749146469
8 190842124
7 505680950
7 199148424
5 664206601
8 858960166
2 706982967
9 17885105
0 789061662

output:

565233644

result:

ok single line: '565233644'

Test #29:

score: 9
Accepted
time: 0ms
memory: 3784kb

input:

10 2706858
8 20780016
2 612818354
3 550413138
1 565798966
5 236857307
4 422818113
6 141418944
0 660351593
7 74422537
5 669426759

output:

10827432

result:

ok single line: '10827432'

Test #30:

score: 9
Accepted
time: 0ms
memory: 3648kb

input:

10 79131102
3 561812059
10 629590644
0 775921462
3 65546214
4 47956310
6 9533026
6 413541633
10 724465012
3 978513343
1 717560726

output:

289354632

result:

ok single line: '289354632'

Test #31:

score: 9
Accepted
time: 0ms
memory: 3564kb

input:

10 83256
6 698120
3 1534802
8 437707384
5 212414104
7 468360049
4 878752
1 981212200
10 272656828
2 719985274
10 752429067

output:

83256

result:

ok single line: '83256'

Test #32:

score: 9
Accepted
time: 0ms
memory: 3564kb

input:

10 1
5 14274
2 570420826
5 355150629
6 357632129
8 528001647
7 934027175
6 481321503
4 1273104
6 3094
1 814868110

output:

13

result:

ok single line: '13'

Test #33:

score: 9
Accepted
time: 0ms
memory: 3584kb

input:

10 2873864
10 977169433
10 847905313
10 124227633
10 549266764
0 236666415
10 890433448
10 661097582
10 564499162
10 343958722
10 854023415

output:

103459104

result:

ok single line: '103459104'

Test #34:

score: 9
Accepted
time: 0ms
memory: 3576kb

input:

10 1000000000
10 508707288
10 58470524
10 321845938
10 323290860
10 776749224
0 1000000000
10 137965772
10 524047258
10 180390059
10 713703265

output:

8000000000

result:

ok single line: '8000000000'

Test #35:

score: 9
Accepted
time: 0ms
memory: 3580kb

input:

10 226214084
8 824556953
8 508286392
8 477565118
8 145272502
8 540447972
8 460840516
8 206666089
8 591816141
8 254840354
8 927809299

output:

3198106772

result:

ok single line: '3198106772'

Test #36:

score: 9
Accepted
time: 0ms
memory: 3780kb

input:

10 10
9 420719880
9 174634535
9 936752657
9 381266133
9 833058617
9 372254594
9 794099768
9 388422457
9 540952494
9 456683771

output:

450

result:

ok single line: '450'

Test #37:

score: 9
Accepted
time: 0ms
memory: 3500kb

input:

10 24
10 840795537
10 863928462
10 786445929
10 613005621
10 931415607
10 658396805
10 900315095
10 500448499
10 565668068
10 999965883

output:

1080

result:

ok single line: '1080'

Test #38:

score: 9
Accepted
time: 0ms
memory: 3588kb

input:

10 35179030
2 869884177
2 957349278
0 979089717
2 874549497
3 940925611
3 727713012
0 960781959
3 724210350
3 988081346
1 897834835

output:

914654780

result:

ok single line: '914654780'

Test #39:

score: 9
Accepted
time: 1ms
memory: 3652kb

input:

10 106
0 424
0 212
0 318
0 530
0 954
0 742
0 636
0 1060
0 106
0 848

output:

1802

result:

ok single line: '1802'

Test #40:

score: 9
Accepted
time: 1ms
memory: 3564kb

input:

10 121
0 1936
0 1694
1 726
0 2420
0 1452
1 484
1 1210
1 968
1 242
0 2178

output:

2662

result:

ok single line: '2662'

Test #41:

score: 9
Accepted
time: 0ms
memory: 3860kb

input:

10 172
2 1032
2 516
0 3612
0 4128
1 2580
0 4644
0 5160
1 2064
1 3096
2 1548

output:

4472

result:

ok single line: '4472'

Test #42:

score: 9
Accepted
time: 0ms
memory: 3632kb

input:

1 685041057
4 990761589

output:

0

result:

ok single line: '0'

Subtask #4:

score: 33
Accepted

Dependency #3:

100%
Accepted

Test #43:

score: 33
Accepted
time: 1ms
memory: 3864kb

input:

40 775287934
15 627598219
0 879640425
2 583623769
28 674296588
8 742162320
40 709091851
37 567907921
34 577543751
0 733598362
23 583109809
31 945393785
40 637430437
34 890099810
24 952303758
10 925604686
4 753214661
11 718708236
22 868289856
11 829766025
10 925608457
19 640362335
10 644476892
16 930...

output:

2661444590

result:

ok single line: '2661444590'

Test #44:

score: 33
Accepted
time: 0ms
memory: 3832kb

input:

40 496463
28 738084705
15 898550967
40 763074368
32 837986867
32 942216033
13 856836487
20 793001875
32 914058962
28 948460805
19 996421342
29 891979805
8 837113574
13 787002223
12 780641428
13 722451752
25 788970866
34 988435567
2 965013102
0 754168493
27 872232667
12 995001749
20 875486433
25 8033...

output:

45178133

result:

ok single line: '45178133'

Test #45:

score: 33
Accepted
time: 1ms
memory: 4024kb

input:

40 354788490
31 418636662
38 361966458
11 741919909
36 624686847
30 237930654
20 848553776
30 739580296
18 627923142
25 948765010
8 944204212
16 800271029
36 348066617
31 385966481
19 586438622
1 993551164
19 542191870
6 994378654
2 993440875
23 621889579
5 997776307
21 695891186
38 125106033
15 811...

output:

1178620474

result:

ok single line: '1178620474'

Test #46:

score: 33
Accepted
time: 1ms
memory: 3856kb

input:

40 11186912
21 819188396
10 863121127
8 812385287
28 919787402
31 529034016
40 940607967
4 946875031
23 691115613
12 829788973
9 958529656
8 910218011
36 438089052
35 424777334
40 63540247
21 789028269
14 660910075
0 882265146
1 997603098
16 630082472
32 504122218
9 935130843
36 638881853
38 8287389...

output:

901880583

result:

ok single line: '901880583'

Test #47:

score: 33
Accepted
time: 1ms
memory: 3848kb

input:

40 189215091
9 785347338
3 923017130
31 330735433
14 678414157
40 180812380
6 808086774
0 931879612
10 749407928
40 10099534
20 717211897
3 914780644
25 395309185
21 479040565
15 561967472
11 732351796
0 993236962
22 565931686
26 681136152
9 767799019
37 69639665
4 878680793
19 685731462
28 39284954...

output:

1877955067

result:

ok single line: '1877955067'

Test #48:

score: 33
Accepted
time: 1ms
memory: 3848kb

input:

40 23921
8 758795362
26 311762913
17 490489115
3 998193112
6 908359476
9 741782519
29 810388119
21 316551139
22 561360478
12 728408380
29 248844508
40 929576745
25 336561770
18 424465462
8 776686456
22 552902337
3 963791848
8 827724982
5 941082218
19 367014450
39 168240533
7 828050546
23 902420297
3...

output:

1507023

result:

ok single line: '1507023'

Test #49:

score: 33
Accepted
time: 1ms
memory: 3880kb

input:

40 223384422
6 817027789
19 478289788
4 893349646
24 178222165
29 123934589
7 807764344
26 169628132
32 184112455
10 805849019
6 874162373
38 72990476
40 3160499
12 953758576
1 963383453
39 44537575
5 820099306
34 684862959
22 239123115
20 474255973
35 74613631
16 586597076
27 131047742
30 113421885...

output:

895742306

result:

ok single line: '895742306'

Test #50:

score: 33
Accepted
time: 1ms
memory: 3916kb

input:

40 8613387
20 496577340
9 661428616
4 788254889
31 212735347
16 568485882
33 182323447
14 616915188
22 427473303
15 593254234
8 670777569
27 342252459
6 705881042
9 762460542
10 760606059
3 937950997
34 78436392
21 440406206
17 519339896
28 993102611
18 516103955
24 411202222
5 728670714
36 52101197...

output:

637390638

result:

ok single line: '637390638'

Test #51:

score: 33
Accepted
time: 1ms
memory: 3832kb

input:

40 982897772
10 676261773
0 955495507
22 450070334
30 340939334
32 300447466
11 647427687
17 531207490
1 912879078
40 15042514
25 379263192
9 718365595
3 887974792
5 857744808
36 130808013
6 824152563
27 361775332
12 621652042
2 900293338
31 313136750
8 734907256
4 862894460
21 450941120
37 88100188...

output:

0

result:

ok single line: '0'

Test #52:

score: 33
Accepted
time: 1ms
memory: 3912kb

input:

40 646014
1 911280203
2 900613585
37 100592262
4 831994976
39 46561929
7 768801576
29 316916668
0 951152970
30 315026417
34 199240769
12 624585259
20 534428063
14 613492285
23 496137014
18 546678096
13 621195264
38 86346027
24 437178045
3 879725425
22 518155152
35 179991908
17 565401094
32 306689917...

output:

0

result:

ok single line: '0'

Test #53:

score: 33
Accepted
time: 1ms
memory: 4056kb

input:

40 76500852
29 764334047
2 909920465
7 789003198
3 892756475
2 929932612
29 488502396
23 388479006
15 545763482
21 4328296
5 890573589
27 682963225
7 976834617
33 577793888
31 571993268
16 120951208
31 551033169
18 29490364
19 18417167
26 868197819
27 206
3 989368179
3 963631170
22 829390738
14 6384...

output:

1220895627

result:

ok single line: '1220895627'

Test #54:

score: 33
Accepted
time: 1ms
memory: 3904kb

input:

40 202955
15 956807142
24 6121302
28 3368
30 789577719
6 738372159
9 690512721
18 338132561
17 22613524
13 557177702
35 543526688
2 971373499
7 707237695
16 27484190
5 785849780
5 934668217
4 922921023
23 547416447
27 17045
40 598917299
33 502246724
11 618777229
34 202372625
37 304039930
23 6848598
...

output:

12819224

result:

ok single line: '12819224'

Test #55:

score: 33
Accepted
time: 1ms
memory: 4068kb

input:

40 157615
38 478992657
28 568653189
6 862231507
0 978758995
19 232177501
7 809672092
14 116157228
15 774050
37 214309509
33 175535848
21 11811
29 1
9 642489416
18 52669
25 511613359
32 31770657
27 583
29 400352594
25 613353666
8 690911287
40 451910608
24 7421
11 945054014
4 879849429
19 883845551
4 ...

output:

5107153

result:

ok single line: '5107153'

Test #56:

score: 33
Accepted
time: 0ms
memory: 4616kb

input:

40 218253
0 822728709
40 749188003
40 756303665
40 80288435
40 565742184
40 625034493
40 94968178
40 609164706
40 826226081
40 889559686
40 782092883
40 785981880
40 780774401
40 693860736
40 442153729
40 770441373
40 67746385
40 964497827
40 914713295
40 215624676
40 93901278
40 794865119
40 834833...

output:

150682525

result:

ok single line: '150682525'

Test #57:

score: 33
Accepted
time: 0ms
memory: 4472kb

input:

40 1000000000
40 880460960
40 701301591
40 118972220
0 1000000000
40 210641233
40 918598644
40 36678728
40 469366744
40 17713115
40 358446264
40 692824266
40 902470994
40 612812683
40 802023511
40 642907096
40 407524586
40 85390101
40 383427800
40 100909769
40 628081507
40 708288968
40 513348159
40 ...

output:

38000000000

result:

ok single line: '38000000000'

Test #58:

score: 33
Accepted
time: 1ms
memory: 4024kb

input:

40 903010436
3 186429052
3 866752174
3 438394119
3 465436648
3 856133870
3 131418921
3 46639173
3 193584395
3 368739657
3 766824538
3 302137043
3 179377030
3 26027844
3 63835158
3 374542542
3 254256067
3 227075725
3 119560589
3 56828488
3 218269937
3 469620862
3 522623910
3 893194687
3 906726006
3 4...

output:

36206465076

result:

ok single line: '36206465076'

Test #59:

score: 33
Accepted
time: 0ms
memory: 3840kb

input:

40 5
24 615571454
24 335194138
24 524152280
24 870549924
24 256269835
24 505451503
24 794555132
24 627639447
24 854459108
24 600772752
24 204618462
24 586213748
24 730253837
24 895096691
24 108800262
24 802392995
24 892254633
24 750987219
24 249701195
24 366844201
24 471890316
24 278282690
24 986241...

output:

3900

result:

ok single line: '3900'

Test #60:

score: 33
Accepted
time: 1ms
memory: 4064kb

input:

40 32
40 996797796
40 592358781
40 603851912
40 679989936
40 899949930
40 916795808
40 797670897
40 674069551
40 656215435
40 666817637
40 663956165
40 588439879
40 521795122
40 590395520
40 780868144
40 956998722
40 776530006
40 621569649
40 694190301
40 786991921
40 571657644
40 711117000
40 67737...

output:

24960

result:

ok single line: '24960'

Test #61:

score: 33
Accepted
time: 1ms
memory: 4036kb

input:

40 87823983
8 800623384
3 978315302
5 907771877
6 875197995
4 979257882
0 981730121
7 928229656
7 877723481
0 992406401
7 901758989
4 956513810
5 939739074
7 812911471
7 837275945
1 976411864
5 905584852
4 943240793
8 903423450
7 855489781
5 972922876
6 960114042
4 986715108
6 999502288
3 951322491
...

output:

5274686165

result:

ok single line: '5274686165'

Test #62:

score: 33
Accepted
time: 1ms
memory: 4056kb

input:

40 182
0 26208
0 24752
1 19656
0 22568
3 6552
0 23296
3 728
1 21840
2 8736
2 10192
2 9464
1 16016
2 11648
3 4368
0 26936
3 3640
2 13832
0 25480
2 14560
1 16744
3 5096
3 7280
2 10920
1 17472
1 15288
0 27664
3 1456
1 18928
1 20384
2 8008
0 24024
1 21112
3 2912
3 5824
1 18200
2 13104
0 29120
3 2184
2 1...

output:

30940

result:

ok single line: '30940'

Test #63:

score: 33
Accepted
time: 1ms
memory: 4056kb

input:

40 161
4 21896
4 25760
1 42504
0 48944
4 24472
5 19320
2 38640
0 47656
2 34776
1 41216
0 51520
7 5152
2 37352
6 10304
1 43792
5 14168
3 28336
7 3864
5 15456
2 33488
5 18032
3 29624
5 16744
7 1288
3 27048
1 39928
6 12880
1 45080
3 30912
7 6440
7 2576
4 23184
4 20608
6 7728
0 50232
6 9016
6 11592
2 36...

output:

39928

result:

ok single line: '39928'

Test #64:

score: 33
Accepted
time: 1ms
memory: 3820kb

input:

40 187
5 51612
1 78540
9 22440
8 26928
6 40392
3 60588
0 87516
11 4488
7 33660
6 38148
10 11220
4 56100
11 6732
9 17952
1 76296
4 58344
0 89760
7 35904
10 8976
5 49368
9 15708
2 74052
8 24684
4 53856
6 44880
8 29172
3 62832
1 80784
0 83028
3 65076
9 20196
7 31416
6 42636
2 71808
3 67320
5 47124
11 2...

output:

55726

result:

ok single line: '55726'

Test #65:

score: 33
Accepted
time: 1ms
memory: 3852kb

input:

40 100000
13 2806040
18 306699
8 7825610
10 5505511
20 1016
17 604060
10 5509977
12 3614670
9 6618564
16 1003260
8 7829146
15 1508442
4 13617068
19 102230
6 10536240
5 12038800
17 601864
1 19034660
13 2801936
5 12033616
7 9129988
7 9103976
19 103736
4 13608415
6 10523550
1 19033680
18 300711
20 1470...

output:

21000076

result:

ok single line: '21000076'

Test #66:

score: 33
Accepted
time: 1ms
memory: 3868kb

input:

40 100000
1 19031780
12 3615903
2 17134770
9 6602808
14 2115344
6 10533720
4 13615623
19 104776
12 3603456
3 15315570
7 9101652
11 4511570
17 604464
13 2806304
2 17144745
13 2812128
3 15319206
20 1656
8 7800728
16 1003520
16 1000505
5 12001040
19 103780
15 1503204
11 4520630
18 302757
10 5500462
8 7...

output:

21000924

result:

ok single line: '21000924'

Test #67:

score: 33
Accepted
time: 1ms
memory: 3912kb

input:

40 100000
12 3609909
16 1000585
14 2101841
10 5502420
1 19031020
18 307071
6 10533495
2 17136556
9 6609600
12 3603474
20 468
19 102456
19 100684
18 301797
1 19033060
11 4523200
2 17141914
13 2810608
8 7827274
15 1503870
14 2116884
5 12014672
8 7815600
7 9105810
3 15309090
4 13631127
16 1010150
3 153...

output:

21000700

result:

ok single line: '21000700'

Subtask #5:

score: 27
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Dependency #4:

100%
Accepted

Test #68:

score: 27
Accepted
time: 31ms
memory: 221968kb

input:

300 205990967
288 725913461
70 793829139
58 974079315
85 838121943
4 916535584
245 912604548
211 853719954
39 933109227
108 728635978
274 877560834
181 962262372
185 732797812
172 805442869
125 809276446
154 759264769
267 891201102
145 951771770
224 746681811
138 837723232
1 926546556
272 904823557
...

output:

2473371129

result:

ok single line: '2473371129'

Test #69:

score: 27
Accepted
time: 24ms
memory: 226992kb

input:

300 7535
129 741389303
141 605785259
134 733652280
36 649567538
175 863648541
118 911425086
204 833058635
202 600876081
161 943883883
10 631702797
223 895961836
138 771340572
271 648396273
114 884736938
229 905778171
79 875660863
267 995269535
222 945323593
267 858085698
47 851437205
231 575730719
2...

output:

21098000

result:

ok single line: '21098000'

Test #70:

score: 27
Accepted
time: 19ms
memory: 222736kb

input:

300 274094232
243 381074819
15 992625070
118 503950852
235 377403063
6 987281382
216 293763358
197 665688609
229 383422773
26 913438087
245 427992236
112 516392754
251 808263532
97 891225961
245 393682569
297 224700861
236 868605559
29 970884466
57 800913205
64 926172235
174 719759964
263 414239844
...

output:

2496077992

result:

ok single line: '2496077992'

Test #71:

score: 27
Accepted
time: 27ms
memory: 227052kb

input:

300 2967367
282 148340596
57 900691181
72 901502619
69 869545340
21 999424007
207 857716342
75 946661868
230 716402839
297 243458725
26 998872934
149 938447381
221 255515282
256 994366341
126 625510205
90 844235685
48 953106805
113 663873216
71 791148015
16 993937053
64 990413493
241 278898074
120 6...

output:

1159798435

result:

ok single line: '1159798435'

Test #72:

score: 27
Accepted
time: 24ms
memory: 227888kb

input:

300 859203554
166 676377693
241 603619806
215 945676508
48 953753578
61 810938561
56 854437236
195 393702512
237 959987158
251 207715001
88 855717393
291 55420657
15 976786391
193 724938720
46 888954475
20 981686508
31 960462970
294 49362006
47 964337883
55 947965487
62 810890452
285 496018177
230 1...

output:

3835042200

result:

ok single line: '3835042200'

Test #73:

score: 27
Accepted
time: 16ms
memory: 228248kb

input:

300 30730025
184 982238248
275 97367864
115 590353043
191 318279845
137 788362128
45 846776049
103 648315585
147 731095070
108 957930128
87 705771062
95 688484791
106 699606432
3 992852784
260 131331748
277 144054267
214 600919192
181 758752131
153 955816988
207 636158059
184 351571254
89 912272889
...

output:

1548197547

result:

ok single line: '1548197547'

Test #74:

score: 27
Accepted
time: 15ms
memory: 224152kb

input:

300 782757990
36 900789376
40 866010011
191 828827375
154 486286303
279 111758742
169 704366821
114 631027987
132 565524461
217 294374117
244 201819153
142 518569680
169 451952330
116 628183512
128 688805144
275 122613304
120 618989927
131 567084796
159 478389352
86 740606855
60 803745286
63 8316523...

output:

2551293097

result:

ok single line: '2551293097'

Test #75:

score: 27
Accepted
time: 12ms
memory: 223172kb

input:

300 100199
128 564471785
252 211465950
167 452526350
147 520603730
72 703944156
205 294722899
57 749817739
184 362420280
180 398777336
300 3464693
149 513268186
103 643343755
219 260767569
252 168219359
165 458826696
245 682833569
38 807296740
104 634412528
278 68418948
84 686398332
196 500297511
20...

output:

93986662

result:

ok single line: '93986662'

Test #76:

score: 27
Accepted
time: 12ms
memory: 219928kb

input:

300 583095488
114 659520453
249 197343497
41 893108741
66 802956142
34 912406758
131 577946021
298 4561333
5 982328336
213 305979407
22 932984264
157 506466401
12 964119712
63 818933653
42 889844150
192 375286021
36 905353906
123 595766648
255 168351147
248 198344553
109 692257065
162 495376729
177 ...

output:

0

result:

ok single line: '0'

Test #77:

score: 27
Accepted
time: 19ms
memory: 219784kb

input:

300 57207
250 147065861
168 450072326
97 626302834
191 335466045
7 972575472
167 450183861
151 486068990
64 752015385
126 529620148
53 795683641
145 500345220
255 126393621
100 614827244
140 504973111
124 534611266
195 322275693
190 338553965
289 29962062
216 241074693
108 596406110
98 625265421
128...

output:

0

result:

ok single line: '0'

Test #78:

score: 27
Accepted
time: 15ms
memory: 219864kb

input:

300 255669
221 24605
189 4121468
159 830060106
135 56831818
28 885245058
201 1416190
119 94844615
242 389351797
101 516085072
50 813898848
43 940872935
96 540032862
15 960256681
130 923082761
166 16010058
167 15773076
114 108076652
190 3739404
90 553621875
67 703122095
162 18206786
156 26101965
278 ...

output:

322441546

result:

ok single line: '322441546'

Test #79:

score: 27
Accepted
time: 31ms
memory: 219800kb

input:

300 30
79 724085520
143 2503828
7 987408757
7 979872743
222 414671534
82 590490032
127 8754402
120 865882891
7 990898316
125 172799091
177 356534826
7 967290527
122 11910627
178 549247619
71 774531289
98 949351881
30 851654263
218 88
32 831138786
12 969547031
151 1899016
68 928444887
197 103234
97 5...

output:

148630

result:

ok single line: '148630'

Test #80:

score: 27
Accepted
time: 16ms
memory: 219872kb

input:

300 4771
165 13914
259 712362590
51 765450805
186 1766
86 888666131
185 1876
107 6111345
254 757268040
58 706866005
211 57
133 332986
46 756841710
209 80
77 802793339
253 190080689
65 753342392
167 752491901
141 194052
274 70818985
127 637768421
256 437534639
171 8293
110 5199597
295 215765129
73 62...

output:

9194506

result:

ok single line: '9194506'

Test #81:

score: 27
Accepted
time: 346ms
memory: 433808kb

input:

300 261495
300 442863797
300 558620718
300 467833882
300 918060280
300 514173404
300 938826137
300 433462170
300 616556980
300 979526936
300 945706953
300 644963816
300 956980410
300 394752253
300 581616174
300 554736865
300 341364222
300 406003147
300 603393259
300 901833067
300 410484309
300 46557...

output:

287731250

result:

ok single line: '287731250'

Test #82:

score: 27
Accepted
time: 338ms
memory: 433660kb

input:

300 1000000000
300 509799684
300 916803893
300 70424055
300 754001790
300 613021187
300 218719869
0 1000000000
300 36905447
300 438899840
300 922645194
300 61565629
300 401199094
300 419905157
300 388845945
300 382606654
300 613465886
300 699672059
300 380637451
300 373165836
300 752879810
300 65530...

output:

298000000000

result:

ok single line: '298000000000'

Test #83:

score: 27
Accepted
time: 309ms
memory: 219804kb

input:

300 15099909
233 470359764
233 672758505
233 338130059
233 688698764
233 825958228
233 19875374
233 654804305
233 776867427
233 59362004
233 873738232
233 520545182
233 97188098
233 217532077
233 344876933
233 18983556
233 403962847
233 856280354
233 182070874
233 573431032
233 20415654
233 28940228...

output:

5845836449

result:

ok single line: '5845836449'

Test #84:

score: 27
Accepted
time: 309ms
memory: 219924kb

input:

300 8
202 715991116
202 871731414
202 792401004
202 140042608
202 989879124
202 179426707
202 721813356
202 676403422
202 644209215
202 413970887
202 642640490
202 441301341
202 180501128
202 336134413
202 389976000
202 552236993
202 823386294
202 594210811
202 110306740
202 504021094
202 751464596
...

output:

358800

result:

ok single line: '358800'

Test #85:

score: 27
Accepted
time: 309ms
memory: 219804kb

input:

300 91
300 948869843
300 879237535
300 515549831
300 630054644
300 834388436
300 614468079
300 643449165
300 795903523
300 500448656
300 925363634
300 644912334
300 708841440
300 748715462
300 769190651
300 786229380
300 952784947
300 599726204
300 766970696
300 935563106
300 987224171
300 969759005...

output:

4081350

result:

ok single line: '4081350'

Test #86:

score: 27
Accepted
time: 260ms
memory: 219920kb

input:

300 58610902
9 988964272
18 964700526
23 976865008
11 968974788
11 980325787
7 987023126
17 992835354
20 953395076
10 975459664
18 961986285
17 953742883
12 953883691
14 994502727
9 980045985
15 962792704
21 938143597
23 950900761
13 997736183
8 994883877
11 954700432
5 997099923
16 948638349
19 973...

output:

19539986344

result:

ok single line: '19539986344'

Test #87:

score: 27
Accepted
time: 250ms
memory: 219820kb

input:

300 186
27 117180
1 1595880
28 66960
0 1640520
21 463140
10 1071360
2 1551240
13 920700
12 982080
14 864900
4 1445220
0 1657260
29 11160
26 206460
4 1428480
4 1406160
4 1411740
2 1528920
25 279000
4 1400580
26 200880
6 1294560
3 1489860
10 1099260
26 184140
27 133920
16 781200
27 167400
25 256680
27...

output:

1137018

result:

ok single line: '1137018'

Test #88:

score: 27
Accepted
time: 211ms
memory: 219868kb

input:

300 107
42 577800
23 1174860
46 436560
56 128400
1 1868220
6 1714140
28 1014360
57 70620
55 134820
21 1239060
25 1123500
10 1585740
28 1007940
53 218280
48 365940
33 841020
9 1630680
10 1579320
58 38520
51 276060
5 1746240
9 1624260
59 12840
55 141240
33 866700
36 763980
17 1380300
45 462240
16 1399...

output:

1045390

result:

ok single line: '1045390'

Test #89:

score: 27
Accepted
time: 143ms
memory: 219932kb

input:

300 135
21 2782350
87 97200
39 2053350
57 1336500
10 3219750
55 1385100
33 2272050
75 595350
88 60750
46 1761750
76 546750
22 2721600
70 801900
47 1725300
60 1202850
50 1591650
5 3438450
24 2660850
63 1057050
8 3304800
73 668250
31 2357100
13 3110400
47 1713150
0 3608550
7 3341250
13 3086100
32 2332...

output:

1648215

result:

ok single line: '1648215'

Test #90:

score: 27
Accepted
time: 52ms
memory: 270492kb

input:

288 96
141 1000000000
208 1000000000
141 1000000000
294 1000000000
294 1000000000
141 1000000000
141 1000000000
116 1000000000
208 1000000000
294 1000000000
294 1000000000
294 1000000000
208 1000000000
208 1000000000
294 1000000000
294 1000000000
294 1000000000
208 1000000000
141 1000000000
208 1000...

output:

34311

result:

ok single line: '34311'

Subtask #6:

score: 0
Time Limit Exceeded

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Dependency #4:

100%
Accepted

Dependency #5:

100%
Accepted

Test #91:

score: 0
Time Limit Exceeded

input:

300 494556201
810485125 438070239
66213405 134393910
674094868 178072620
607727580 911993802
714614339 147346632
164241277 908327413
806149331 663416074
568510676 287718865
287786049 373911058
385093094 502483086
923075937 676334400
827443857 796808835
563102759 81357216
756573084 724653619
57524901...

output:


result: