QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#790237 | #9643. 串联 | wsyear | 100 ✓ | 994ms | 47604kb | C++20 | 3.0kb | 2024-11-28 08:56:53 | 2024-11-28 08:56:59 |
Judging History
answer
#include <bits/stdc++.h>
#define rep(i, j, k) for (int i = (j); i <= (k); ++i)
#define per(i, j, k) for (int i = (j); i >= (k); --i)
#define SZ(v) int((v).size())
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
using ll = long long;
using pii = std::pair<int, int>;
using pll = std::pair<ll, ll>;
template<class T>inline void chkmn(T &x, T y) { if (y < x) x = y; }
template<class T>inline void chkmx(T &x, T y) { if (y > x) x = y; }
using namespace std;
const int maxn = 200010;
int n, sz[maxn], mxsz[maxn], vis[maxn], bel[maxn], id[maxn], pid[maxn], L[maxn], R[maxn], len, tot, asz, rt;
ll a[maxn], b[maxn], lim, mna[maxn], sumb[maxn], ans, cmn;
vector<int> e[maxn];
void findrt(int u, int fa) {
sz[u] = 1, mxsz[u] = 0;
for (int v : e[u]) {
if (v == fa || vis[v]) continue;
findrt(v, u), sz[u] += sz[v];
chkmx(mxsz[u], sz[v]);
}
chkmx(mxsz[u], asz - sz[u]);
if (mxsz[u] <= asz / 2) rt = u;
}
void dfs(int u, int fa, int be) {
bel[u] = be, id[++len] = u, sz[u] = 1;
for (int v : e[u]) {
if (v == fa || vis[v]) continue;
mna[v] = min(mna[u], a[v]), sumb[v] = sumb[u] + b[v];
dfs(v, u, be), sz[u] += sz[v];
}
}
void fz(int l, int r, int u) {
if (l == r) {
sort(id + L[l], id + R[l] + 1, [&](int x, int y) { return mna[x] > mna[y]; });
return;
}
int mid = (l + r) >> 1;
fz(l, mid, u), fz(mid + 1, r, u);
int cl = L[l], cr = R[mid], dl = L[mid + 1], dr = R[r], tot = cl - 1;
set<ll> S;
int pos = dl;
rep (i, cl, cr) {
while (pos <= dr && mna[id[pos]] >= mna[id[i]]) {
S.insert(sumb[id[pos]]), pos++;
}
auto it = S.lower_bound((lim + mna[id[i]] - 1) / mna[id[i]] - sumb[id[i]] - b[u]);
if (it != S.end()) chkmn(cmn, *it + sumb[id[i]] + b[u]);
}
S.clear(), pos = cl;
rep (i, dl, dr) {
while (pos <= cr && mna[id[pos]] >= mna[id[i]]) {
S.insert(sumb[id[pos]]), pid[++tot] = id[pos++];
}
auto it = S.lower_bound((lim + mna[id[i]] - 1) / mna[id[i]] - sumb[id[i]] - b[u]);
if (it != S.end()) chkmn(cmn, *it + sumb[id[i]] + b[u]);
pid[++tot] = id[i];
}
while (pos <= cr) pid[++tot] = id[pos++];
rep (i, cl, dr) id[i] = pid[i];
}
void solve(int u) {
vis[u] = 1, id[len = 1] = u, L[1] = R[1] = 1;
if (a[u] * b[u] >= lim) chkmn(ans, b[u]);
mna[u] = a[u], sumb[u] = 0, bel[u] = (tot = 1);
for (int v : e[u]) {
if (vis[v]) continue;
mna[v] = min(a[u], a[v]), sumb[v] = b[v];
L[++tot] = len + 1, dfs(v, u, tot), R[tot] = len;
}
cmn = 1e18, fz(1, tot, u), chkmn(ans, cmn);
for (int v : e[u]) {
if (vis[v]) continue;
asz = sz[v], findrt(v, u), solve(rt);
}
}
int main() {
cin.tie(nullptr) -> ios::sync_with_stdio(false);
cin >> n >> lim;
rep (i, 1, n) cin >> a[i] >> b[i];
rep (i, 1, n - 1) {
int u, v;
cin >> u >> v;
e[u].emplace_back(v);
e[v].emplace_back(u);
}
ans = 1e18, asz = n, findrt(1, 0), solve(rt);
cout << ans << '\n';
}
詳細信息
Subtask #1:
score: 15
Accepted
Test #1:
score: 15
Accepted
time: 5ms
memory: 9956kb
input:
1935 100002617107042 3549526 1627445 3659278 5231179 8300710 6537126 3692477 4253254 2314646 7374383 9557660 3973510 2157299 8008856 5349338 9286378 6863965 5295468 6438473 3472437 8623469 5151533 6732744 5135250 9763341 4477819 1198507 4326984 4085755 8151510 4127916 9559825 5382178 3509576 9971869...
output:
10479936
result:
ok single line: '10479936'
Test #2:
score: 15
Accepted
time: 4ms
memory: 4092kb
input:
1971 100000691996565 2103598 9622163 4487235 8720445 4380307 7057318 6240155 8766658 4184502 7515423 1704463 8584340 2811007 6951160 9512006 2266117 8362504 2068427 4229112 8941299 2952150 7792204 1581088 4384220 5994528 4226903 1604304 7007689 9600169 1335687 8370604 5157219 7460688 4960477 6914930...
output:
11141504
result:
ok single line: '11141504'
Test #3:
score: 15
Accepted
time: 4ms
memory: 3888kb
input:
1983 100001553850439 1390471 8373725 4152152 8011586 7880235 4867329 6598575 4598523 7678550 5553716 1573498 7813596 6956498 5940329 5294850 3021950 8553807 1030010 2076488 5534459 1182084 6855575 8387158 7722486 6071583 2464277 8286289 4885466 1936319 3174207 3189515 1366768 9753540 3317719 3849662...
output:
10701114
result:
ok single line: '10701114'
Test #4:
score: 15
Accepted
time: 4ms
memory: 4156kb
input:
1927 100003351938229 3192275 3299496 5630684 3516336 4476042 3507988 7722775 6169426 8178348 8283137 3439079 2122873 5961233 7356897 1254487 4619254 4838418 4236218 6415837 3011434 8007562 9870183 1552526 2559813 5044863 4711889 8088368 9594874 3797519 2845637 5441391 8511329 4497382 3845760 3105856...
output:
11317746
result:
ok single line: '11317746'
Test #5:
score: 15
Accepted
time: 4ms
memory: 4160kb
input:
1987 100001330852095 5762711 6136317 3231303 3551982 4927533 5867528 1817360 9880735 9796958 7054450 7600257 4630508 8108348 3560218 5385906 8297160 3174098 4875077 6083307 3562721 1122501 9373766 9875657 7477320 4540883 5896453 2965472 2786388 8144966 1723495 4677343 3451774 9358401 4255211 4910602...
output:
11064293
result:
ok single line: '11064293'
Test #6:
score: 15
Accepted
time: 4ms
memory: 3876kb
input:
1995 100003379470494 2159064 3993567 6204650 7163106 4467952 8805337 8012214 7073506 3105001 5990175 8648815 7123912 9968824 7532393 4329742 3413342 3931287 1566236 9723607 9589428 4175044 8949341 5554633 7186564 9187055 5287217 8702434 7939849 8002894 2482586 5080559 9567363 4610537 9890149 1626511...
output:
11506703
result:
ok single line: '11506703'
Test #7:
score: 15
Accepted
time: 4ms
memory: 3804kb
input:
1982 100000767594946 5597760 3847159 1583159 3021842 5581632 1526220 2343244 7031674 4027561 3006768 7918430 9266709 7208210 1341347 8082640 9960766 3102443 6738794 2918486 4572414 5759220 1561720 8039985 6072471 1615189 2584807 9356345 3161984 3101051 3869417 1917321 7317457 4488365 2266216 4403623...
output:
11212936
result:
ok single line: '11212936'
Test #8:
score: 15
Accepted
time: 0ms
memory: 3800kb
input:
1945 100000772724254 9865667 4167237 2107080 5511704 5187488 5793540 5224042 3028952 1496025 5739774 4760433 4904976 8244458 9546030 3622460 3183192 3987254 6318700 5324961 8835334 5837449 9939171 6723269 1222576 1099080 2639246 8477992 1541119 2946621 4777441 9402894 7755943 8468016 4315963 4816187...
output:
10869957
result:
ok single line: '10869957'
Test #9:
score: 15
Accepted
time: 4ms
memory: 3876kb
input:
1930 100000451326765 1039106 5121964 7987282 6829062 6938347 7503664 9750466 8945093 9470902 8311859 1625601 3347631 4642526 6762428 4779574 4961568 1954217 9232868 5441223 8438035 2505709 7671901 1067803 5420751 6942082 1845724 7546254 7917525 1026887 4934622 1915427 4073952 7603783 1190044 4167032...
output:
11239000
result:
ok single line: '11239000'
Test #10:
score: 15
Accepted
time: 4ms
memory: 3892kb
input:
1913 100003814692834 7059545 4499258 2551512 7336099 4351441 4600396 6915747 6908156 3891860 9095088 3315314 2911686 9888472 5690580 1434904 5625736 7403892 4145739 2994494 6319247 7123772 2307216 4109002 5381243 5582054 6674569 8508045 9463027 8582113 5134882 1917706 5709360 3640259 2599766 8461399...
output:
10428958
result:
ok single line: '10428958'
Test #11:
score: 15
Accepted
time: 3ms
memory: 3956kb
input:
2000 443873123 4438732 1 7073 73057 8334 6810 4438732 1 4438732 1 4438732 1 4438732 1 7959 34772 4438732 1 4779 74771 4825 1826 4114 82622 7515 55610 3553 75085 1663 43103 4438732 1 4438732 1 4438732 1 9488 17416 4438732 1 4438732 1 4438732 1 8882 54476 3892 29429 4438732 1 3852 99676 4438732 1 7720...
output:
100
result:
ok single line: '100'
Test #12:
score: 15
Accepted
time: 0ms
memory: 3904kb
input:
2000 2567102235 1951 78228 2929 44714 256713 1 3228 21668 3195 19367 256713 1 423 60941 7318 39217 256713 1 1771 36243 538 77624 4770 69714 353 54372 4538 61165 3563 60485 8820 61683 3299 58688 4984 10128 256713 1 2423 88726 256713 1 256713 1 256713 1 256713 1 3730 64799 256713 1 6020 4453 256713 1 ...
output:
386206
result:
ok single line: '386206'
Test #13:
score: 15
Accepted
time: 4ms
memory: 4124kb
input:
2000 1726807031 3651 27424 8668 29785 726808 1 8026 12235 9532 33835 7628 73709 981 91763 4457 54863 8019 91030 2532 38289 1956 52813 2311 66731 2486 62485 6666 75306 6860 83276 726808 1 359 26614 726808 1 726808 1 7511 44459 644 47378 9701 97996 726808 1 726808 1 726808 1 726808 1 726808 1 726808 1...
output:
215066
result:
ok single line: '215066'
Subtask #2:
score: 15
Accepted
Test #14:
score: 15
Accepted
time: 19ms
memory: 4996kb
input:
9772 100001635009487 6105477 9592965 2446558 4081788 3544307 1498494 1158072 8593648 2722648 8107870 7463502 6028672 1128603 1768366 2691462 2490920 1577521 7479612 4254188 3702455 2401701 1962198 6092604 6450289 9341997 6406106 1917654 5247247 6146524 7167452 3394606 7672593 9007250 7454473 6281744...
output:
10781826
result:
ok single line: '10781826'
Test #15:
score: 15
Accepted
time: 21ms
memory: 4816kb
input:
9066 100004226621364 1740518 6601687 3921518 7818908 3706648 9433445 9974006 6400908 8624646 9927553 7171517 4099662 2889954 9420495 9535765 4082011 9274713 2251055 8108453 8199095 2046416 4032639 4828543 8449524 4218737 2216220 5658160 9114351 2627227 5010812 7563956 7828528 6217342 3286955 4569753...
output:
10986553
result:
ok single line: '10986553'
Test #16:
score: 15
Accepted
time: 22ms
memory: 5260kb
input:
9391 100001393244059 3253884 9527331 9717791 2528608 6181718 7283607 7011819 8414728 2973564 4566253 8341749 1949256 3934392 7753162 4150295 8444978 6963461 5328778 3643536 1432145 2629996 2395914 7870489 3754759 1806604 2313573 7085332 3241652 7848175 2573848 5457876 9004241 4242330 8085049 3620819...
output:
10940902
result:
ok single line: '10940902'
Test #17:
score: 15
Accepted
time: 23ms
memory: 5064kb
input:
9626 100000166942620 6442651 1826623 9247400 9192956 9995909 2979009 4857697 4094447 2882631 8039904 4567976 6654287 6508049 4137114 6075019 3410952 2219353 8975890 3527328 7729220 5215177 3537904 6860256 6621101 6949818 6305955 8562902 9039534 9764253 6946659 1210328 9676433 4508417 1319169 7941971...
output:
10375768
result:
ok single line: '10375768'
Test #18:
score: 15
Accepted
time: 23ms
memory: 5072kb
input:
9657 100000488448934 8511937 9704622 1806100 5040809 2435873 6868975 2325756 6847822 1471700 1374442 7993438 2893382 1032591 8604218 8295227 7464026 5025473 1824040 7792443 3664155 2917212 1969873 5308415 6972573 3755415 6866651 3351919 3378288 7856957 9137960 2786068 6349657 2300599 1566738 1694163...
output:
10636860
result:
ok single line: '10636860'
Test #19:
score: 15
Accepted
time: 24ms
memory: 4824kb
input:
9348 100004235713160 5126441 1253529 6942942 3856766 7407585 7721822 8513019 1216794 4047246 4090116 5816382 2509972 9675824 6801988 4690536 8004954 7655640 2530479 1747055 3816210 5300653 6494315 9355817 2318301 7280072 4964662 7826825 5981332 2578934 1799645 4848406 2771896 5719873 1534262 4558994...
output:
10499519
result:
ok single line: '10499519'
Test #20:
score: 15
Accepted
time: 22ms
memory: 5144kb
input:
9456 100002206594852 3156631 9931295 5822353 2346521 8048079 7266800 4908659 6362162 5670151 2762237 7210862 1054494 9015700 9178386 2345527 7738445 7274032 1557525 6161488 9662995 9516708 9611955 7774878 2383767 1493592 5772094 5971863 7336123 3735655 2147182 3350987 8358656 3298763 2682458 9692438...
output:
10347385
result:
ok single line: '10347385'
Test #21:
score: 15
Accepted
time: 21ms
memory: 5004kb
input:
9462 100000788713534 7239653 1567369 4304815 9097724 6133358 8088013 5519769 7568531 3654555 4934633 5406560 5138219 9022789 4106442 2130871 4791129 7595297 5521654 3015487 2419454 5991474 8509611 9403962 7756231 6084874 7185277 9399911 8613005 5670807 8341400 3335880 1132131 6369388 8787347 7760834...
output:
10688383
result:
ok single line: '10688383'
Test #22:
score: 15
Accepted
time: 18ms
memory: 5000kb
input:
9398 100001152419719 4331712 3433495 4215238 9839512 4083618 4238298 6497946 6004662 7510645 7752425 3224753 8729343 3020351 9313282 6312319 6615149 2889403 1093187 2058189 3399107 2796341 6705883 6347810 4782243 1586370 1794209 8568264 5579196 7299121 8971413 4153208 9616157 3102096 4903930 7200903...
output:
10792821
result:
ok single line: '10792821'
Test #23:
score: 15
Accepted
time: 24ms
memory: 4888kb
input:
9678 100003731533383 6209408 9856769 3907282 6918838 7350593 8918458 7867585 3393227 5951178 5056676 7899496 3544094 1548735 9463181 5998525 8854409 8235863 9565462 7959507 4370000 6135923 1478337 6636253 7450874 1907658 9717043 5250115 3148181 9410458 3620397 6242029 7947947 6818297 1122671 6484804...
output:
10524587
result:
ok single line: '10524587'
Test #24:
score: 15
Accepted
time: 16ms
memory: 5124kb
input:
9000 2546287870 565842 1 565842 1 8692 52515 8197 3696 4215 38675 565842 1 4219 85145 204 7182 565842 1 565842 1 565842 1 565842 1 565842 1 7436 51080 565842 1 6031 82307 565842 1 7993 50214 7709 85541 565842 1 5503 39 4018 21312 565842 1 9972 89387 7972 43318 6424 88027 565842 1 565842 1 565842 1 6...
output:
315565
result:
ok single line: '315565'
Test #25:
score: 15
Accepted
time: 16ms
memory: 5096kb
input:
9000 3577471707 794994 1 7187 97693 794994 1 794994 1 794994 1 794994 1 794994 1 794994 1 6088 54736 794994 1 858 3646 794994 1 4325 49145 794994 1 8828 8981 308 42518 1301 15269 794994 1 1269 18105 794994 1 794994 1 794994 1 794994 1 2562 8297 794994 1 794994 1 7769 81285 7438 72582 794994 1 794994...
output:
536706
result:
ok single line: '536706'
Test #26:
score: 15
Accepted
time: 15ms
memory: 5124kb
input:
9000 4710817005 1046849 1 1046849 1 6400 81586 3297 80662 1046849 1 1046849 1 7236 38208 8892 2922 2227 38475 1046849 1 1766 5068 6687 96287 511 44892 1046849 1 1046849 1 6669 70465 1046849 1 1046849 1 1046849 1 876 39982 1046849 1 7213 16152 6286 3332 3797 16918 1046849 1 2239 65591 3749 25028 8134...
output:
646319
result:
ok single line: '646319'
Subtask #3:
score: 15
Accepted
Test #27:
score: 15
Accepted
time: 521ms
memory: 32104kb
input:
199998 100004130186324 3352699 4354450 7345378 4717865 6884528 5360708 8446213 6146508 8452875 8731152 9911476 8488596 5132982 8228726 2511731 8301731 7950999 4157882 9453240 2023463 7037057 9438422 9440756 2823577 9759370 9536497 7953412 4176946 2271735 3600297 1933248 1696214 3170616 9708900 85838...
output:
24901018
result:
ok single line: '24901018'
Test #28:
score: 15
Accepted
time: 514ms
memory: 32096kb
input:
199991 100000947961236 7342358 5698369 9246871 3313405 6637704 1068588 8505368 5769626 5606111 1583956 5201444 7653762 1765659 4034928 9596884 6554713 5583599 4173690 1641409 7154794 3228321 3261000 8634324 1198584 4123621 3612351 2769120 7281412 9307010 8762942 6780704 3017337 2983671 1140939 55994...
output:
25251337
result:
ok single line: '25251337'
Test #29:
score: 15
Accepted
time: 608ms
memory: 32124kb
input:
199993 100001778284371 2203843 8757596 6753187 4598484 3599064 1321102 6397939 2335494 1723828 4309164 6762409 6350587 7960217 8027766 5780326 8737261 6371925 2700490 3378007 9407250 1475827 8640491 1353321 8948211 4393774 5691579 5281445 1812365 6886680 7458325 7082333 8502378 8864113 9034507 24122...
output:
14368033
result:
ok single line: '14368033'
Test #30:
score: 15
Accepted
time: 600ms
memory: 32188kb
input:
200000 100004019297266 3171054 8950221 2093375 8118451 6768668 6463985 1876237 8228002 5482223 5630131 4723267 3295555 3473536 2523465 4383658 7384611 3515507 7046153 6298470 3461508 9121419 8471366 8804081 5153323 3556499 9883164 9102895 5563559 8310217 2307983 8606259 2191515 7036097 6359618 33925...
output:
11874626
result:
ok single line: '11874626'
Test #31:
score: 15
Accepted
time: 570ms
memory: 32124kb
input:
199993 100003506644913 5898885 1676802 8069469 6922381 5876836 4360322 8174093 4007930 4951713 6162110 7088788 1999614 2745512 1378548 7290573 3742231 4223202 6576251 6753242 1908892 3258307 7925239 1675309 4953073 2097830 1548037 3874660 1691843 1939059 6970486 4772531 4542606 7612787 6733830 87994...
output:
23107138
result:
ok single line: '23107138'
Test #32:
score: 15
Accepted
time: 588ms
memory: 32148kb
input:
200000 100000112148489 8257804 1715964 3684943 7960216 1881751 1004175 7004456 9420963 7627175 5718187 2134929 5887330 5333027 1555639 3761544 7151442 1532823 5718896 7296930 2615714 7709573 6770473 4995724 3451389 9826946 5495041 8206630 1995030 3491840 5288886 7194789 4050212 5231232 8951393 47283...
output:
10949430
result:
ok single line: '10949430'
Test #33:
score: 15
Accepted
time: 571ms
memory: 31992kb
input:
199990 100000065329264 5536956 2717134 9391109 9587393 3073161 9452270 1052551 1655471 5124753 5154041 6196205 7729383 1146178 5817719 3736628 7158373 7728032 5713947 3556545 4546084 8994189 6648757 5985127 5744842 5946296 1335039 3149096 9367208 1327221 7755347 8324191 8044611 4631260 9758747 98371...
output:
10406054
result:
ok single line: '10406054'
Test #34:
score: 15
Accepted
time: 572ms
memory: 32056kb
input:
199992 100003347403346 8162638 6640013 8554799 4146836 8662277 6821621 8540349 1809911 5416052 1651798 3714287 5214981 1121181 2921951 4343057 3684897 6374622 2582365 1027604 4683481 9823129 6954613 4410253 1316042 3200878 1542466 6353808 7712579 1877829 5328701 6653496 7032198 2278061 1012082 73362...
output:
13022124
result:
ok single line: '13022124'
Test #35:
score: 15
Accepted
time: 562ms
memory: 32032kb
input:
199997 100000368665079 8258216 2718527 4616272 9889151 1619417 4757533 8198528 9954004 5529947 5132249 1095134 4043481 6539161 7125398 1008379 6295245 1115777 5101169 4369588 5603093 3942197 2635070 2351461 2589574 6421533 5221637 6026897 4833681 9606335 2713063 3055533 3559576 8717969 4911854 38161...
output:
10814428
result:
ok single line: '10814428'
Test #36:
score: 15
Accepted
time: 579ms
memory: 32088kb
input:
199990 100000120493275 8384902 6689802 5373972 3772660 7321494 2564920 1730643 7483359 1705239 9536245 1742824 6743388 8568042 6615475 5828766 5860054 9036382 4903876 8877092 2352025 4003870 6691792 5503493 9162874 8540511 8261186 6184430 3104234 8409040 2541869 2318779 6320677 2184167 5025368 61892...
output:
12176377
result:
ok single line: '12176377'
Test #37:
score: 15
Accepted
time: 566ms
memory: 31828kb
input:
200000 502912943995 199123 803643 941248 831922 708998 167058 123382 65803 467436 885266 38611 585026 36765 867750 904615 467276 44268 159164 976859 800194 50658 465959 689659 73827 949321 821619 728338 788155 701715 96232 355851 973274 180280 314354 285040 565521 941726 339051 475425 216154 78090 4...
output:
506157
result:
ok single line: '506157'
Test #38:
score: 15
Accepted
time: 572ms
memory: 31828kb
input:
200000 500213537791 926944 636679 999033 504732 185766 377644 130135 433792 399332 115080 232143 264533 942204 971789 778950 989420 293745 48447 93032 132540 59511 955701 545109 765875 849102 21873 347640 774804 261528 635664 716566 263558 284755 252192 945340 339188 111858 213034 804433 338422 9174...
output:
501794
result:
ok single line: '501794'
Test #39:
score: 15
Accepted
time: 467ms
memory: 31720kb
input:
200000 900003139415 886679 916109 153627 196890 973019 415819 384948 535441 446317 540611 792727 432341 477163 825329 122570 707611 586643 793986 977028 550747 878539 697638 318871 284693 297724 481323 337267 536437 575335 101768 358690 902481 930418 704899 81089 523831 384756 354681 637841 384853 2...
output:
904433
result:
ok single line: '904433'
Subtask #4:
score: 15
Accepted
Test #40:
score: 15
Accepted
time: 364ms
memory: 47300kb
input:
199990 10003188838297 4211327 3820876 7698984 8359653 5066640 7948487 8284258 7942725 1523122 8506553 8839078 3332090 2286508 2775336 2137304 5706348 5156807 1709018 1370762 6336028 4873462 5648510 1731080 9104872 9546417 3513558 8372504 5527023 1886687 8042824 7075090 8975678 7078482 8268817 547400...
output:
1008614
result:
ok single line: '1008614'
Test #41:
score: 15
Accepted
time: 350ms
memory: 47400kb
input:
199999 10002892355528 5616464 2944799 5772471 7437719 6455477 1153785 8845516 1736216 7541571 6737585 6753821 4807148 7443244 1663563 2095696 4467453 4368446 7743374 8259067 9071855 4734198 1482386 7480742 4656492 4934179 3922246 9913203 6156126 3403717 6473378 7676983 2227587 4479830 4041223 368774...
output:
1007012
result:
ok single line: '1007012'
Test #42:
score: 15
Accepted
time: 346ms
memory: 47300kb
input:
199997 10002540820180 2754035 9858195 1595534 2907220 4946408 8642691 7896342 1300619 5111215 7329949 4088966 2809675 9679494 6112691 2577541 4528373 1879949 8536567 1829262 4177071 3844112 9633619 7640307 8952100 7701837 4556731 9749883 9712552 2713201 6204511 7520267 1230545 6569198 3921105 565105...
output:
1010168
result:
ok single line: '1010168'
Test #43:
score: 15
Accepted
time: 343ms
memory: 47296kb
input:
199997 10004112875807 6921794 2508174 9118576 5783130 6189752 5065631 6769433 6894201 6233398 4248171 8452881 4197303 2573176 7798809 6402462 6799228 7331875 1796377 6646698 5237625 7281887 1049730 6914159 5311568 2181386 2057139 1459456 5580607 6943011 9522460 3065862 4971688 6568179 5762797 505170...
output:
1009449
result:
ok single line: '1009449'
Test #44:
score: 15
Accepted
time: 352ms
memory: 47312kb
input:
199991 10001724540843 4491882 1453695 4356435 3409089 6855752 8219883 6430172 1614670 3843148 1022645 4269813 7258614 5244547 9207415 3845135 4562284 1695124 5869919 4001271 9528847 5020509 9774407 9513114 3495639 2982036 6693341 9503117 1179466 8083309 3824054 6695164 7547434 1541019 2999212 533629...
output:
1006038
result:
ok single line: '1006038'
Test #45:
score: 15
Accepted
time: 339ms
memory: 47240kb
input:
199999 10000389140505 3680143 4839269 7873331 5843155 5763444 1776610 7952234 8357516 7867978 5690313 8627617 3586698 5821751 1011367 9430152 1979769 9149950 8872531 2691551 2314677 8818458 1067616 5445138 2612596 2643010 3270830 2336588 8448919 3769434 8303475 9507925 1676238 8661829 5446050 910339...
output:
1007783
result:
ok single line: '1007783'
Test #46:
score: 15
Accepted
time: 352ms
memory: 47560kb
input:
199994 10003636621292 9946882 3223288 6515088 9195492 8277841 3457848 4069679 1215207 7181644 7823713 3472846 7725111 4988995 8844252 6216786 2885600 9224549 5839119 2734798 8204235 4723466 3990811 7940052 6774106 3155510 7632144 8266153 2675956 6529839 2762325 3418256 6580832 8346492 2389404 903124...
output:
1010104
result:
ok single line: '1010104'
Test #47:
score: 15
Accepted
time: 352ms
memory: 47296kb
input:
199994 10002185448805 7781921 6978590 1010673 9623739 7819541 6654644 7790666 6221961 9048824 7665354 7873449 1969643 8741447 4281216 6486632 6783074 4103765 9784839 9626058 5247565 5713991 1593716 8773484 9114570 8903689 8907538 1731278 2469311 1800416 1233909 2448508 6155251 8232167 8846978 930738...
output:
1008427
result:
ok single line: '1008427'
Test #48:
score: 15
Accepted
time: 352ms
memory: 47364kb
input:
199997 10001386420983 8066582 1147291 6651364 3490714 7337487 3128455 3502395 4057361 9107246 6859397 8616442 9207941 3284920 5977517 6392479 8004977 1606988 3269444 7463397 5722977 6626564 6188500 9083616 5542187 8615236 5414984 2055744 2346462 9233048 8889314 1377785 2484192 7816741 4853641 529468...
output:
1006587
result:
ok single line: '1006587'
Test #49:
score: 15
Accepted
time: 350ms
memory: 47028kb
input:
199997 10003846281617 9863808 8749861 8291906 3652162 8922421 9888378 6786126 7376908 2643872 5727827 8487239 5819553 3023723 8337888 6486663 9801774 5696617 6457997 3410735 2459783 9306526 8266016 5918224 4881120 9746442 9177364 7839090 4649236 5372951 5013269 3557565 9080622 1202016 8287845 729980...
output:
1003586
result:
ok single line: '1003586'
Test #50:
score: 15
Accepted
time: 373ms
memory: 47360kb
input:
200000 5003203842030 90768 425892 139402 114145 427635 950672 635764 247663 550279 598107 909639 361897 706306 377873 662140 222260 77403 246946 877677 1874 121969 618959 991479 517325 224525 329398 852256 177688 666055 719211 335497 552386 597746 593476 562488 677214 725310 409879 477054 856893 567...
output:
10758908
result:
ok single line: '10758908'
Test #51:
score: 15
Accepted
time: 360ms
memory: 47368kb
input:
200000 5004018142398 727922 305793 508172 485363 451889 146561 629147 563105 765742 931642 915743 584927 408689 936490 69688 838552 711163 902846 704239 408963 590241 99044 790056 517813 839392 631830 48475 748636 139437 438621 314762 974 284745 57065 101984 323513 912206 995177 195843 760804 810681...
output:
8854580
result:
ok single line: '8854580'
Test #52:
score: 15
Accepted
time: 380ms
memory: 47604kb
input:
200000 250282302446 258537 70514 334855 870833 359647 967772 59695 442619 781108 861813 404610 864678 337908 208419 179926 733204 226924 434662 829128 543276 281909 661129 692263 115208 991757 947317 562302 743141 398731 956259 661140 324720 390480 494642 250358 763255 855732 758198 181539 989103 47...
output:
251786
result:
ok single line: '251786'
Subtask #5:
score: 20
Accepted
Test #53:
score: 20
Accepted
time: 165ms
memory: 19092kb
input:
49990 100000994385852 8754571 7380604 2240806 6151788 3314007 8112341 6984100 8481029 1194110 4487530 6444114 5193786 5723011 8911491 9068179 9599365 9949744 6860180 3973585 2935971 9594995 4665326 7245966 1871321 9147881 9702198 6028928 7824679 3618152 5786003 5979819 9771693 1794062 1126052 135005...
output:
10369035
result:
ok single line: '10369035'
Test #54:
score: 20
Accepted
time: 149ms
memory: 20208kb
input:
49992 100004002878575 8714909 5904557 5343919 5624995 3893242 8710590 6644194 8995121 9191794 5841931 2714285 9087669 1032620 3946709 9126637 7755368 3445097 4330990 6367559 5034978 8296658 7686112 4445663 2496916 8998660 9073977 5329275 9474311 6969956 1383194 6374472 1394375 4199182 1628422 862119...
output:
10195114
result:
ok single line: '10195114'
Test #55:
score: 20
Accepted
time: 160ms
memory: 18924kb
input:
49991 100000835180386 5972336 7804521 3966834 3433350 2164050 8263526 4441639 2159017 3055650 4897053 9528929 3414325 7353706 4857477 2054337 5628442 9589153 2754631 6327953 6866435 4477068 7526379 7447306 6134383 7214660 9150685 2369977 7720762 1007759 8247250 8570896 1753651 8155455 1850569 512178...
output:
10144655
result:
ok single line: '10144655'
Test #56:
score: 20
Accepted
time: 160ms
memory: 20680kb
input:
49992 100000659771851 5896744 4228448 5563383 5459108 2253005 8442262 6400154 7040639 2734664 5427683 6315870 6867975 9190882 4448291 1671953 8001753 2444830 1406513 2068103 9979037 2074698 9356807 7832167 6566815 4407630 4205487 3504453 1491654 9224369 1520564 4958585 6358806 5504453 9292830 119066...
output:
10173050
result:
ok single line: '10173050'
Test #57:
score: 20
Accepted
time: 159ms
memory: 21136kb
input:
49991 100000667354859 3602133 6664081 8139753 4716773 6491428 9127310 9253401 6648069 1300420 3269502 7937564 9548089 5089324 7718656 1041851 5617096 3474866 6574345 8236107 3587879 6900048 4075902 1568728 9544118 4650152 2173051 7283709 2349612 5088679 2821480 3870625 5250752 9911957 3968883 555473...
output:
10337841
result:
ok single line: '10337841'
Test #58:
score: 20
Accepted
time: 165ms
memory: 18816kb
input:
49990 100003413107192 9106139 2930295 2868188 7280998 3063788 9682642 3084418 3005401 3287290 3930970 8665571 4396949 5775698 9527304 7308381 9902282 8470746 6811121 7785523 6690001 6347405 3328929 9162594 3283376 9170671 4275454 3436319 1690188 8704785 5320530 6681419 5875111 1850825 9619756 855177...
output:
10483590
result:
ok single line: '10483590'
Test #59:
score: 20
Accepted
time: 167ms
memory: 19532kb
input:
50000 100002791997982 9200308 9679649 6971450 2273473 4055335 8273886 6305239 7456423 5927416 6948982 8424874 9950383 6012166 7371211 7030770 1659880 9877657 5501201 6576229 9030349 8398430 3546602 6699281 9601610 8950078 7758972 1393014 3860692 1166985 2217198 8995774 8207150 7847242 9147060 201470...
output:
10462654
result:
ok single line: '10462654'
Test #60:
score: 20
Accepted
time: 159ms
memory: 18768kb
input:
49998 100001700367683 6228858 8901501 2366073 2807765 1368896 8612986 1699912 9106500 5769652 9113982 9687486 9187283 6921653 2218601 1853280 3236537 9423316 3058055 7252157 4519852 9258303 1723448 9302829 9809272 4508829 8830950 2982416 9695246 1548023 7472032 8344361 6143837 1099593 9161631 278267...
output:
10514206
result:
ok single line: '10514206'
Test #61:
score: 20
Accepted
time: 170ms
memory: 20116kb
input:
49991 100003292112872 6709318 4187241 7136690 3308424 9565684 1024211 8758201 5815053 4579251 9821515 1595427 4244497 4128145 7735828 7301147 7089123 3920355 1722559 9451530 3843730 2522581 9592717 8908481 4801557 1752331 3771739 1101932 3244063 9724085 3093202 8750962 6065025 2013405 6548794 341587...
output:
10169440
result:
ok single line: '10169440'
Test #62:
score: 20
Accepted
time: 170ms
memory: 18928kb
input:
49997 100000357490249 4161434 2051901 3621786 5177094 7080234 9834673 1185148 2682670 4358962 5074602 5399329 7786118 1911365 7885394 3806080 9526687 7010406 7991231 2696526 4323487 5531825 9789306 9175467 3512111 5314004 9541126 3419570 2977656 2370744 2665130 7699963 2472222 6975102 9520874 835511...
output:
10325131
result:
ok single line: '10325131'
Test #63:
score: 20
Accepted
time: 129ms
memory: 16380kb
input:
50000 14286545889 4016 16219 571462 1 7015 224691 571462 1 2491 115493 571462 1 8689 946323 571462 1 6787 139685 571462 1 571462 1 571462 1 571462 1 571462 1 571462 1 571462 1 571462 1 7416 924736 571462 1 5924 457858 571462 1 571462 1 4849 359671 6733 15973 2740 584472 571462 1 571462 1 3719 747637...
output:
1528409
result:
ok single line: '1528409'
Test #64:
score: 20
Accepted
time: 133ms
memory: 19444kb
input:
50000 14017071351 727 973512 4921 190454 3658 512797 3728 268021 6874 712790 560683 1 7842 591343 560683 1 560683 1 4863 609152 4821 507643 6407 356 4853 565325 461 222771 560683 1 9186 253228 560683 1 560683 1 9892 196778 3484 55340 560683 1 9553 738078 560683 1 560683 1 1049 298688 560683 1 9353 2...
output:
1473253
result:
ok single line: '1473253'
Test #65:
score: 20
Accepted
time: 122ms
memory: 19424kb
input:
50000 12512383741 5724 210551 412 823600 500496 1 7370 492885 1372 644717 6137 602924 500496 1 9952 137495 500496 1 500496 1 4184 29817 500496 1 500496 1 2228 997177 500496 1 9588 317131 5247 943961 6409 745728 500496 1 500496 1 120 908379 500496 1 8729 895546 7894 405057 500496 1 500496 1 2858 4453...
output:
1304658
result:
ok single line: '1304658'
Test #66:
score: 20
Accepted
time: 120ms
memory: 16364kb
input:
50000 13892098006 8211 246714 5992 506776 6453 97919 555684 1 555684 1 2713 336095 555684 1 555684 1 4337 805818 555684 1 555684 1 555684 1 555684 1 3084 199934 5360 539567 5933 329265 4266 636512 3664 93848 555684 1 555684 1 555684 1 8298 138578 555684 1 5820 268753 555684 1 1476 942665 555684 1 55...
output:
1485546
result:
ok single line: '1485546'
Subtask #6:
score: 20
Accepted
Test #67:
score: 20
Accepted
time: 929ms
memory: 33624kb
input:
199990 100004231755893 8188750 4873620 4552453 6246559 9803815 8778380 7562427 7965226 4387027 7384336 4591418 7954720 2314277 7137407 3606907 4028084 6999739 4472967 4802931 4761929 1437045 7520376 5023737 7211510 7897214 6615679 4438283 6095313 6433812 6877440 9470655 1578766 4363540 1827990 62248...
output:
10144203
result:
ok single line: '10144203'
Test #68:
score: 20
Accepted
time: 990ms
memory: 31948kb
input:
199991 100003940288286 8349828 5288010 9220180 8258421 2722541 6932650 1205337 6487974 7073303 1322800 1885775 8782769 2291461 6187748 3643608 4060186 5814975 4117645 2408462 6080671 3767055 7267977 7722454 4113651 2872014 4298343 9702651 6829944 9829467 5795267 5053269 4830789 1867307 6811107 14678...
output:
10114201
result:
ok single line: '10114201'
Test #69:
score: 20
Accepted
time: 912ms
memory: 32836kb
input:
199995 100003848705416 4332432 1871593 3465178 6799210 5021688 3298102 6045649 9751287 4013668 1001714 1892952 6920790 6979191 8152780 2160266 8776670 9742723 1733338 6207649 7020006 2178275 5238481 3461221 8989228 9434476 6335129 3536240 9781726 6617997 2636006 6926956 7869481 2003729 2469277 49385...
output:
10328999
result:
ok single line: '10328999'
Test #70:
score: 20
Accepted
time: 994ms
memory: 35256kb
input:
199993 100003510275130 4067292 8663827 5214361 8287402 1499615 1063554 6391664 3056438 2894557 1176734 9964571 7579519 5951199 5720758 6371142 9451340 8541606 1738798 2986597 6240965 8166077 8130498 7499315 5181698 3096642 8819593 1549525 6339956 9417730 5562612 4813368 8858991 8708552 1533370 19816...
output:
10257484
result:
ok single line: '10257484'
Test #71:
score: 20
Accepted
time: 878ms
memory: 32408kb
input:
199990 100003866255190 6344868 3265131 9399029 4205952 3300852 5672041 9130639 3382674 7088936 8047295 4393268 1472292 9431317 4282818 4013527 3549012 3796451 9557587 3404014 7426222 4327895 3654760 5663129 6909933 6996282 8119770 3044319 7259404 2104957 8077322 4274362 7347426 4549800 6708781 88405...
output:
10221826
result:
ok single line: '10221826'
Test #72:
score: 20
Accepted
time: 972ms
memory: 32848kb
input:
199999 100004046855227 6116168 8221603 2514325 6762978 3417474 3609893 8163488 6480191 3615304 2364510 2749431 6712867 6364771 1168440 3615239 3094745 7075338 6812060 2732903 1344389 2654331 7622156 2400509 3746161 9108409 8282807 3877057 9606888 8725165 9252136 4035903 1223461 9403481 3020090 92535...
output:
10167349
result:
ok single line: '10167349'
Test #73:
score: 20
Accepted
time: 899ms
memory: 32388kb
input:
199997 100002226735507 7746621 6858207 3619418 6137957 5875281 2936429 9139190 8502523 6726005 8508547 1644854 3555442 7486221 4579436 9213732 9865994 6240592 6406319 2010080 1500671 1442606 8852473 5599942 6607937 5827800 4767341 6645077 6910963 7805162 9317483 9253754 4508162 2493086 3112478 50645...
output:
10241265
result:
ok single line: '10241265'
Test #74:
score: 20
Accepted
time: 976ms
memory: 31040kb
input:
199996 100000857133124 8834846 1820919 1278767 2282260 7369832 3514477 9153291 4850048 1746376 9324646 4240891 9121404 8117258 8126638 6878315 4006385 4194025 5157945 1202791 4085806 9494129 4809058 3913276 9749105 8107798 9673618 6037209 8666422 6191457 4556032 8641673 1728605 6346971 2885149 70973...
output:
10141529
result:
ok single line: '10141529'
Test #75:
score: 20
Accepted
time: 949ms
memory: 32884kb
input:
199999 100003600611737 7796769 9294884 2433200 2102845 6077931 9465945 9579743 7520772 2954939 4697938 6026370 4039233 3927095 4170532 1583478 5713134 5711693 9771234 8224061 1221717 2191511 9120077 6226741 9641940 6301876 9714292 6536216 3227670 3356220 4499161 9864643 1798270 8704124 3507638 12654...
output:
10192514
result:
ok single line: '10192514'
Test #76:
score: 20
Accepted
time: 970ms
memory: 32216kb
input:
199998 100002581493931 6321339 3780932 7139343 5701855 7905734 7798168 9563349 9832321 1098944 3728605 2062946 2153543 6744704 4017974 9589469 3779955 7820492 2060165 5669357 1266916 1352600 4021230 9980722 1036000 9644042 3246444 1501342 2904381 7411136 3755882 6157111 7959097 8447842 5012623 27564...
output:
10166876
result:
ok single line: '10166876'
Test #77:
score: 20
Accepted
time: 732ms
memory: 37312kb
input:
200000 1999272595135 100032726 1 817143 655809669 354101 858902107 381566 608907907 100032726 1 32429 573753950 100032726 1 100032726 1 970645 306465894 100032726 1 349906 890276917 100032726 1 100032726 1 701274 34380625 100032726 1 100032726 1 921082 757080263 100032726 1 100032726 1 100032726 1 1...
output:
19987
result:
ok single line: '19987'
Test #78:
score: 20
Accepted
time: 720ms
memory: 35656kb
input:
200000 103478118132 51579 26131 35007 423089 10034782 1 10034782 1 87940 334462 10034782 1 24047 294784 24924 581706 10034782 1 10034782 1 10034782 1 10034782 1 10034782 1 10034782 1 82847 659177 73180 872477 10094 129734 71739 585534 92451 319917 10034782 1 10034782 1 30183 783314 8615 496808 51720...
output:
10312
result:
ok single line: '10312'
Test #79:
score: 20
Accepted
time: 737ms
memory: 35548kb
input:
200000 402882515919 10028826 1 10028826 1 627234 38369411 10028826 1 53293 684987107 279796 631083916 681887 372582645 603065 686025291 713009 164373844 10028826 1 10028826 1 848952 374614603 10028826 1 859791 896288848 119658 370808541 10028826 1 10028826 1 564603 203010055 10028826 1 466975 252482...
output:
40173
result:
ok single line: '40173'
Test #80:
score: 20
Accepted
time: 682ms
memory: 35084kb
input:
200000 452109718205 10021098 1 10021098 1 451392 8762812 993235 597907403 10021098 1 10021098 1 10021098 1 132979 185769152 10021098 1 23030 472243875 148002 45179788 193226 98806827 182403 372426654 10021098 1 10021098 1 81001 852973327 10021098 1 844051 225814559 10021098 1 10021098 1 285145 89586...
output:
45116
result:
ok single line: '45116'