QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#47462 | #2222. TomTom Cruise | tovarisch | AC ✓ | 13ms | 6460kb | C++ | 2.8kb | 2022-09-10 03:58:11 | 2022-09-10 03:58:12 |
Judging History
answer
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
#include <array>
using namespace std;
/* *
*
* Too many mind, no mind.
*
* */
const int maxn = 1e4 + 10, logn = 32, oo = 1e9;
using pii = pair <int, int>;
int par[maxn], depth[maxn], up[maxn][32];
long long weight[maxn], dis[maxn];
vector <pii> graph[maxn];
vector <int> tree[maxn];
void dfs(int u, int prev) {
up[u][0] = prev;
for (int i = 1; i < logn; i++) {
up[u][i] = up[up[u][i - 1]][i - 1];
}
for (int& v : tree[u]) {
if (v == prev) continue;
depth[v] = depth[u] + 1;
dfs(v, u);
}
}
int lca(int u, int v) {
if (depth[v] > depth[u]) swap(u, v);
for (int i = 0; i < logn; i++) {
if ((depth[u] - depth[v]) >> i & 1) u = up[u][i];
}
if (u == v) return u;
for (int i = logn - 1; i >= 0; i--) {
if (up[u][i] != up[v][i]) u = up[u][i], v = up[v][i];
}
return up[u][0];
}
int main() {
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
int n, m; cin >> n >> m;
int root = n;
long long mn = oo;
for (int i = 0; i < n; i++) {
cin >> weight[i];
graph[i].push_back({weight[i], root});
graph[root].push_back({weight[i], i});
dis[i] = oo;
mn = min(mn, weight[i]);
}
for (int i = 0; i < m; i++) {
int u, v, w; cin >> u >> v >> w;
graph[u].push_back({w, v});
graph[v].push_back({w, u});
}
priority_queue <pii, vector <pii>, greater <pii>> q;
q.push({0, root});
while (!q.empty()) {
int u = q.top().second;
long long d = q.top().first;
q.pop();
if (dis[u] < d) continue;
for (auto& e : graph[u]) {
int v = e.second, w = e.first;
if (dis[v] > dis[u] + w) {
dis[v] = dis[u] + w;
par[v] = u;
q.push({dis[v], v});
}
}
}
for (int i = 0; i < n; i++) {
tree[i].push_back(par[i]);
tree[par[i]].push_back(i);
}
for (int i = 0; i < maxn; i++) for (int j = 0; j < logn; j++) up[i][j] = root;
dfs(root, root);
long long ans = oo;
for (int i = 0; i < n; i++) {
if (up[i][0] != root) ans = min(ans, dis[i] + weight[i]);
for (auto& e : graph[i]) {
int v = e.second, w = e.first;
if (v == root) continue;
int a = lca(i, v);
if (a == v) continue;
if (a == i) ans = min(ans, dis[v] + weight[v]);
else if (a == root) ans = min(ans, dis[i] + w + dis[v]);
else ans = min(ans, dis[i] + w + weight[v]);
//cout << i << ' ' << v << ' ' << a << ' ' << ans << endl;
}
}
if (!m) ans = 2 * mn;
cout << ans << '\n';
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 12ms
memory: 6160kb
input:
10000 9999 9530 7637 8510 3856 7767 5412 2162 4236 7329 6946 10002 9056 4852 3953 5099 6647 2345 5005 9907 6694 3487 2191 8265 4592 7153 6368 5517 1302 2741 5809 609 8523 3347 5371 2280 7366 7036 694 7854 4265 7540 7756 9573 8645 1610 924 5192 207 5829 1351 3154 5568 3442 1319 10060 495 7587 1829 80...
output:
219
result:
ok single line: '219'
Test #2:
score: 0
Accepted
time: 3ms
memory: 5212kb
input:
30 435 4096 6075 9288 9257 3829 5536 2560 3514 4021 560 6404 128 8127 8150 6848 7656 9002 4894 7797 8799 1143 1139 2102 528 6503 4600 781 7747 8638 6259 1 22 10 5 6 8 17 27 5 7 26 8 10 27 2 11 14 3 7 19 7 4 14 1 8 11 7 4 8 7 0 5 5 9 27 10 9 18 4 11 23 6 14 29 9 26 29 9 7 10 6 9 10 9 14 17 5 18 25 9 ...
output:
659
result:
ok single line: '659'
Test #3:
score: 0
Accepted
time: 1ms
memory: 5356kb
input:
5 10 4442 279 1249 5193 5137 1 2 8 0 3 1 0 1 9 0 4 10 2 3 5 1 3 9 3 4 2 1 4 8 2 4 6 0 2 6
output:
1536
result:
ok single line: '1536'
Test #4:
score: 0
Accepted
time: 2ms
memory: 5408kb
input:
10 45 7047 381 1252 4022 7582 7499 2889 4724 937 8148 3 7 9 0 5 2 2 3 6 1 4 6 0 6 3 6 8 8 0 8 9 8 9 5 4 6 9 0 2 6 1 7 9 0 1 6 3 4 2 5 7 5 2 6 3 1 3 8 2 5 1 1 6 8 6 9 3 0 7 9 4 9 10 4 7 5 2 7 7 4 8 9 1 9 9 1 5 4 3 5 5 7 8 9 5 9 5 7 9 2 4 5 5 1 8 9 3 9 4 1 2 9 0 3 6 2 4 1 6 7 3 0 4 6 3 6 6 2 9 7 3 8 1...
output:
1325
result:
ok single line: '1325'
Test #5:
score: 0
Accepted
time: 3ms
memory: 5264kb
input:
29 406 5418 1178 8660 5649 9385 1446 5610 6221 674 1462 1853 950 1919 2419 4622 5271 3612 4042 4704 1073 5251 4107 3641 7887 5975 5008 3263 4195 7475 2 20 1 13 27 10 9 17 4 18 25 5 4 9 7 14 22 4 4 16 7 19 28 1 9 20 4 14 24 2 1 13 5 8 14 7 2 4 5 14 18 4 9 18 3 9 13 6 15 20 5 11 12 3 18 19 3 22 28 2 8...
output:
1626
result:
ok single line: '1626'
Test #6:
score: 0
Accepted
time: 9ms
memory: 6384kb
input:
10000 10000 4953 3693 6384 9852 6663 4283 1517 7630 3027 7807 2229 1518 8997 9324 1305 6167 6363 3809 4997 9906 6921 9212 1146 1829 8159 8832 4868 7052 7093 5412 9866 1946 9005 2503 8051 1920 6686 9468 5802 5966 3527 4283 7384 8776 9860 4941 4843 6123 5002 6093 5929 8175 1557 6976 9904 5968 5708 467...
output:
283
result:
ok single line: '283'
Test #7:
score: 0
Accepted
time: 3ms
memory: 5288kb
input:
245 245 3584 5764 251 635 1324 332 3798 4345 5835 4756 4743 7046 1098 7885 2137 3395 6146 4426 3656 5222 10086 9277 6232 4789 5700 2956 3803 10033 4597 635 4291 8081 2651 794 4969 3875 7379 5019 4472 3114 6027 5468 6412 7025 3253 8450 320 5651 9128 229 773 9114 9406 6905 156 1358 6113 3859 7643 611 ...
output:
444
result:
ok single line: '444'
Test #8:
score: 0
Accepted
time: 2ms
memory: 5392kb
input:
112 112 7109 960 8425 10018 5021 9839 1364 2900 2285 5405 1476 6272 7779 334 3970 4589 1330 9285 2635 417 7725 1813 3919 6825 3705 7334 1630 2315 1988 5639 4514 5350 2851 9191 1620 7773 5282 9236 573 7467 893 8301 9991 8572 4887 213 3062 6117 5750 1949 6434 3376 3662 6605 6453 3620 3840 7983 5835 20...
output:
550
result:
ok single line: '550'
Test #9:
score: 0
Accepted
time: 13ms
memory: 6232kb
input:
10000 9999 1750 4001 8375 153 6184 7982 1188 4088 6991 1388 7117 9419 6990 3437 7370 5338 1337 6229 3936 1573 8234 3300 547 4482 6646 5138 4331 3786 2889 5719 501 4539 5973 8777 945 2057 3011 2033 2397 9903 9674 9414 5574 2916 2752 2844 8154 3989 8974 1990 1814 3460 1542 2261 4194 8088 3652 4777 812...
output:
331
result:
ok single line: '331'
Test #10:
score: 0
Accepted
time: 7ms
memory: 6440kb
input:
10000 9999 4149 6757 167 6217 4256 5530 6789 9748 6449 2531 8450 2834 4396 4082 8912 4515 4403 5491 8090 5329 144 1120 6381 2353 1236 3455 7372 4627 4573 8766 5035 4974 1775 1454 1091 5931 6884 4133 1932 9586 6564 282 2320 7212 616 1132 7980 1271 6524 5970 2853 2920 3342 5486 5173 4478 8841 8797 900...
output:
269
result:
ok single line: '269'
Test #11:
score: 0
Accepted
time: 4ms
memory: 5384kb
input:
289 544 2667 6329 6016 7447 9462 1485 237 1473 419 2576 2483 5450 10023 4278 1915 3615 2043 8928 8026 2342 4590 8102 3178 5320 8958 9634 7101 3547 7448 9888 1324 6367 2469 3592 3714 1831 4978 203 9556 5297 9032 1939 6999 8955 2469 8814 2471 4413 3995 6749 6655 8485 1103 6085 3706 9961 1971 7059 9760...
output:
360
result:
ok single line: '360'
Test #12:
score: 0
Accepted
time: 4ms
memory: 5300kb
input:
216 402 2648 1732 4635 5947 999 3047 424 9162 232 9112 8659 1702 6656 1803 854 4589 6555 7925 9542 1982 5829 9523 3356 3092 6759 9160 4422 4594 8751 3665 4981 1300 1650 5868 7147 8901 8815 3823 7964 8947 2836 2875 6901 5744 4578 4007 234 7385 1832 6028 5619 3914 5451 8875 3258 8462 7935 7580 2956 65...
output:
495
result:
ok single line: '495'
Test #13:
score: 0
Accepted
time: 3ms
memory: 5400kb
input:
273 512 6544 624 5250 1629 6269 8125 662 2295 4600 3753 3525 3286 303 1008 4969 6242 5300 3629 135 316 7585 9151 3469 1192 7523 7138 4906 6379 1470 5588 636 7914 2464 5786 5795 8633 163 6358 7180 4663 10011 606 4201 214 7866 9071 6357 3066 2600 2744 9634 6437 1795 9355 7529 5571 6393 2335 1850 4115 ...
output:
343
result:
ok single line: '343'
Test #14:
score: 0
Accepted
time: 11ms
memory: 6256kb
input:
10000 9999 5153 7032 7461 2178 7745 3007 2069 7074 8340 1560 4423 5295 1757 8337 1874 9634 5960 9659 3466 2277 4014 1262 5741 8090 7913 6110 9364 7862 1781 1962 5362 3186 8894 9075 1617 2891 8335 9938 9865 6575 7750 540 1770 9408 8777 9896 5294 990 5808 5012 3167 9722 6174 5160 7712 3988 1170 6976 8...
output:
206
result:
ok single line: '206'
Test #15:
score: 0
Accepted
time: 3ms
memory: 5384kb
input:
212 211 2217 9899 2779 1491 2447 8137 2019 3484 3288 2879 8541 3565 6428 8992 6659 2039 3956 3996 4685 9293 6273 6478 2418 9346 6687 9433 2916 6936 605 7395 8163 2722 3546 7195 4113 2246 5232 2384 5630 4773 5164 423 4590 7844 9316 1149 9783 9524 1398 720 5069 7571 3450 7387 3169 10037 6720 5986 6874...
output:
380
result:
ok single line: '380'
Test #16:
score: 0
Accepted
time: 1ms
memory: 5364kb
input:
292 293 4039 4265 5595 1761 7341 7481 6184 7957 2724 992 3646 1542 5046 5089 4112 3476 8363 5128 2808 5916 5963 2235 5195 1083 204 5362 2203 1399 8657 8724 2023 2596 2889 7518 610 6482 1251 6694 4339 3875 3938 4237 1669 5236 5578 2033 8612 193 7061 7673 6009 2925 6160 1105 260 2616 2719 2364 267 127...
output:
329
result:
ok single line: '329'
Test #17:
score: 0
Accepted
time: 0ms
memory: 5380kb
input:
211 212 5079 7507 9832 330 8815 7662 2399 9329 1122 5259 4298 5676 6729 5709 3291 2566 4841 6493 9589 9905 1823 6285 4980 1083 9586 4881 5597 1182 8604 1793 4740 3583 9200 824 165 4268 8386 2464 3497 9408 3976 4048 1336 6957 9657 4527 9424 750 7272 8913 6907 8996 1451 1787 9979 7289 2920 1828 8371 1...
output:
416
result:
ok single line: '416'
Test #18:
score: 0
Accepted
time: 5ms
memory: 6012kb
input:
5455 5455 8870 3713 9781 4223 5208 6261 4547 7553 3397 6731 778 4284 8739 6836 5554 6776 4664 1663 4508 3007 9644 7222 8391 9107 8596 6417 5369 7661 2666 3054 4867 7788 6667 900 1911 8128 3414 2711 5581 3063 5694 6259 3599 685 9347 9053 7361 3912 6968 1769 3171 2865 5243 7814 8224 10092 4131 3493 76...
output:
243
result:
ok single line: '243'
Test #19:
score: 0
Accepted
time: 8ms
memory: 6040kb
input:
5295 5295 7917 1092 7086 5714 536 7857 7312 3306 7233 7083 8767 258 2177 3307 1086 3136 9707 1331 3728 3986 3701 9610 1272 3029 6607 6982 2822 3552 8411 3284 1598 2580 628 4937 8194 1064 2694 1758 4270 6179 8741 9289 2689 7171 8848 10027 6559 8455 1258 187 8694 1212 6050 9866 4141 8909 3100 3215 236...
output:
250
result:
ok single line: '250'
Test #20:
score: 0
Accepted
time: 8ms
memory: 6292kb
input:
10000 10000 6017 2230 5879 1915 1150 7682 9438 2463 9346 4899 9536 8965 398 7052 6523 5969 1237 4081 2246 386 8073 1330 5559 2403 7767 9772 2273 6595 6037 5701 7132 1954 4184 9264 3769 5234 3198 3107 3949 8796 4258 3386 7661 4557 338 4084 6778 7828 4417 5276 4466 8742 6506 9925 1046 526 5949 3219 33...
output:
251
result:
ok single line: '251'
Test #21:
score: 0
Accepted
time: 8ms
memory: 6364kb
input:
10000 10000 4403 9897 157 7432 5926 2611 1786 1837 9889 2707 4282 2143 9154 5149 3929 2571 841 6581 4192 162 5000 6163 6296 8381 888 7844 5891 6032 3864 7272 7246 4519 3422 7303 1851 9248 9815 9889 986 5956 8849 1520 4351 4255 6569 8180 6726 7311 4662 7171 3725 5914 9586 9921 547 374 4017 2690 2658 ...
output:
243
result:
ok single line: '243'
Test #22:
score: 0
Accepted
time: 8ms
memory: 6460kb
input:
10000 9999 1 10000 9999 9998 9997 9996 9995 9994 9993 9992 9991 9990 9989 9988 9987 9986 9985 9984 9983 9982 9981 9980 9979 9978 9977 9976 9975 9974 9973 9972 9971 9970 9969 9968 9967 9966 9965 9964 9963 9962 9961 9960 9959 9958 9957 9956 9955 9954 9953 9952 9951 9950 9949 9948 9947 9946 9945 9944 9...
output:
10001
result:
ok single line: '10001'
Test #23:
score: 0
Accepted
time: 2ms
memory: 5352kb
input:
17 128 1064 7595 8482 9779 6802 6933 730 2205 5829 587 7592 4454 8863 7719 4395 7844 8764 10 12 1 2 11 10 6 7 1 2 15 10 6 9 4 5 16 4 9 16 4 5 6 3 7 8 6 0 12 4 1 9 10 1 2 6 0 9 9 3 11 10 9 11 4 0 13 5 0 6 9 2 6 1 11 12 1 0 15 1 8 14 6 2 10 6 3 15 2 4 16 3 6 16 4 11 14 3 0 11 6 9 10 10 5 8 3 4 5 6 12 ...
output:
1321
result:
ok single line: '1321'
Test #24:
score: 0
Accepted
time: 2ms
memory: 5344kb
input:
17 103 2297 9316 2399 2392 3776 3079 701 1666 9785 2550 7025 7382 9032 2877 4165 3562 7518 6 10 8 8 10 5 3 8 3 5 7 10 11 12 3 12 16 6 1 7 9 5 9 10 5 10 1 10 11 4 12 14 7 7 10 6 3 11 7 6 13 5 6 9 3 4 13 3 7 15 6 5 14 9 1 4 2 0 14 2 5 15 10 5 16 5 8 15 3 7 12 3 7 13 5 7 11 6 2 9 10 1 15 7 14 16 9 3 12...
output:
2371
result:
ok single line: '2371'
Test #25:
score: 0
Accepted
time: 2ms
memory: 5272kb
input:
17 95 5842 572 7156 5595 6482 3694 4503 9038 7107 9476 1582 4424 8017 1085 6472 5895 9694 1 12 2 2 10 7 3 16 2 8 12 10 3 7 6 7 13 5 2 4 10 8 13 5 12 15 5 9 14 1 6 15 4 4 16 7 5 10 5 12 13 5 8 14 8 5 8 9 2 11 2 3 10 5 2 7 3 2 13 6 0 5 5 11 14 5 6 16 3 7 14 4 3 4 8 7 10 2 2 12 9 2 15 3 14 15 10 1 4 10...
output:
1658
result:
ok single line: '1658'
Test #26:
score: 0
Accepted
time: 3ms
memory: 5356kb
input:
17 80 8394 3570 5775 4718 4743 1310 5313 1345 5982 8101 5046 7872 4374 5331 3909 6247 3969 11 15 9 6 10 3 1 14 3 3 14 5 6 14 9 7 14 7 2 11 6 9 12 1 1 6 10 2 14 1 2 8 6 11 14 8 5 6 5 0 1 4 6 12 10 5 13 8 1 7 9 12 15 7 1 3 7 0 15 1 5 16 8 3 10 6 0 2 5 1 8 3 7 13 9 3 15 7 11 12 9 6 16 10 3 16 8 0 4 3 2...
output:
2663
result:
ok single line: '2663'
Test #27:
score: 0
Accepted
time: 3ms
memory: 5416kb
input:
17 59 7240 8107 9375 6080 2172 3941 3578 5690 9673 6795 7734 5304 5188 9366 5379 3897 2682 12 16 5 8 14 3 6 16 9 11 14 1 1 7 9 10 14 2 4 15 10 12 15 7 1 6 10 5 7 2 4 5 5 1 11 7 2 10 3 3 14 7 2 3 10 1 8 3 1 10 3 3 4 6 4 14 4 6 15 8 1 14 10 7 11 9 9 10 9 5 12 8 0 12 3 8 13 3 8 15 2 9 12 9 0 2 5 0 11 6...
output:
4864
result:
ok single line: '4864'
Test #28:
score: 0
Accepted
time: 3ms
memory: 5368kb
input:
16 111 3210 153 4900 1863 565 6599 6951 1883 1395 4021 9092 7295 8449 9934 8090 5405 9 13 9 3 9 2 7 13 10 4 9 1 8 10 9 2 7 9 2 14 1 6 14 9 10 15 5 7 9 7 9 10 3 4 14 2 10 11 9 6 12 3 4 8 4 2 15 2 8 11 10 3 15 5 6 11 2 8 12 3 13 15 1 8 15 7 0 3 8 10 14 5 11 13 6 0 8 3 1 7 2 8 9 6 3 13 6 2 8 10 1 3 9 9...
output:
720
result:
ok single line: '720'
Test #29:
score: 0
Accepted
time: 3ms
memory: 5368kb
input:
16 95 2862 4812 9640 7274 5448 241 5453 3198 7934 9378 6730 4947 5037 8210 1277 950 12 14 8 7 15 3 2 11 4 0 2 6 0 12 8 3 9 3 2 3 5 3 11 1 1 6 3 11 14 8 6 11 6 4 14 8 11 15 7 8 12 9 8 15 1 9 15 8 3 5 2 1 3 6 11 12 8 10 12 3 7 8 9 8 13 5 4 6 3 4 8 2 0 4 2 5 6 6 0 15 4 1 12 4 8 11 6 2 4 6 3 10 2 5 10 5...
output:
1195
result:
ok single line: '1195'
Test #30:
score: 0
Accepted
time: 3ms
memory: 5276kb
input:
16 86 4685 1108 6682 2482 4742 412 7028 1808 1452 6505 894 5431 7515 2310 5733 4440 3 7 2 1 12 1 0 4 8 4 14 9 6 9 6 5 10 6 12 15 2 1 7 9 0 13 4 2 6 7 1 3 3 2 9 10 8 12 7 13 14 9 9 11 10 1 4 6 7 9 7 13 15 8 0 15 10 9 12 7 1 5 1 6 7 5 1 9 9 11 13 9 2 13 4 6 8 3 2 15 4 5 8 9 11 12 3 10 15 9 5 12 8 2 10...
output:
1312
result:
ok single line: '1312'
Test #31:
score: 0
Accepted
time: 2ms
memory: 5364kb
input:
16 70 2251 5704 720 1629 500 1599 9734 399 8674 1058 8938 1581 1753 9407 6222 8422 7 11 9 4 10 3 1 15 1 2 15 7 7 13 3 8 14 10 5 12 8 4 11 5 1 13 3 8 12 10 1 14 2 4 8 6 1 12 8 1 4 2 0 9 2 3 7 10 1 7 10 3 8 4 0 6 4 6 13 10 9 14 8 0 12 3 12 15 6 7 10 8 2 5 9 3 10 10 12 13 2 2 7 4 13 14 6 11 12 6 8 10 5...
output:
906
result:
ok single line: '906'
Test #32:
score: 0
Accepted
time: 1ms
memory: 5408kb
input:
16 59 7990 8059 8099 6623 2544 3644 5691 3731 2662 7675 2720 523 2790 4237 5301 5495 5 7 10 9 11 4 7 15 3 4 15 1 1 12 6 1 4 5 4 6 2 11 13 3 2 7 6 8 10 3 2 13 2 10 12 6 0 10 4 3 12 6 8 11 4 2 12 4 1 5 10 7 11 2 0 12 4 0 9 6 1 11 1 2 6 10 2 9 2 2 10 3 0 7 9 10 13 6 11 15 2 14 15 10 1 2 6 12 15 1 1 3 7...
output:
3070
result:
ok single line: '3070'
Test #33:
score: 0
Accepted
time: 1ms
memory: 5192kb
input:
5 10 999994 1 999995 2 4 1 2 999991 1 3 999991 3 4 999998 2 4 999999 1 4 999992 2 3 999996 0 4 4 0 3 1 0 1 4 0 2 1000000
output:
8
result:
ok single line: '8'
Test #34:
score: 0
Accepted
time: 4ms
memory: 5408kb
input:
100 4950 999994 999992 999995 1000000 999999 999996 999998 999992 999991 999992 999994 999993 999998 999997 999995 999994 999998 1000000 1 999997 999993 999999 1 999991 999996 999999 999993 999991 999998 1000000 999991 999991 999992 999996 999999 999998 999999 999997 1000000 1000000 999997 999992 99...
output:
10
result:
ok single line: '10'
Test #35:
score: 0
Accepted
time: 2ms
memory: 5408kb
input:
100 4950 999994 999992 999995 1000000 999999 999996 999998 999992 999991 999992 999994 999993 999998 999997 999995 999994 999998 1000000 1 999997 999993 999999 1 999991 999996 999999 999993 999991 999998 1000000 999991 999991 999992 999996 999999 999998 999999 999997 1000000 1000000 999997 999992 99...
output:
10
result:
ok single line: '10'
Test #36:
score: 0
Accepted
time: 2ms
memory: 5468kb
input:
100 4950 999994 999992 999995 1000000 999999 999996 999998 999992 999991 999992 999994 999993 999998 999997 999995 999994 999998 1000000 1 999997 999993 999999 999994 999991 999996 999999 999993 999991 999998 1000000 999991 999991 999992 999996 999999 999998 999999 999997 1000000 1000000 999997 9999...
output:
10
result:
ok single line: '10'
Test #37:
score: 0
Accepted
time: 5ms
memory: 5460kb
input:
100 4950 999994 999992 999995 1000000 999999 999996 999998 999992 999991 999992 999994 999993 999998 999997 999995 999994 999998 1000000 999998 999997 999993 999999 999994 999991 999996 999999 999993 999991 999998 1000000 999991 999991 999992 999996 999999 999998 999999 999997 1000000 1000000 999997...
output:
48
result:
ok single line: '48'
Test #38:
score: 0
Accepted
time: 1ms
memory: 5260kb
input:
6 15 999994 1 999995 1000000 1 1 3 5 999997 4 5 999993 1 3 1 1 4 999994 0 5 999997 0 2 1 0 1 999993 1 5 999998 2 4 999998 0 3 999998 0 4 1 3 4 1 1 2 999995 2 3 1000000 2 5 1
output:
4
result:
ok single line: '4'