QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#875498 | #2714. Mountains and Valleys | hhoppitree | 2 | 2002ms | 193632kb | C++17 | 6.3kb | 2025-01-29 21:19:13 | 2025-01-29 21:19:15 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
constexpr int N = 5e5 + 5;
int n, S, T;
vector<int> G[N];
int dep[N];
namespace tree_lca {
int dfn[N], dfn_c, pos[20][N];
int get(int x, int y) {
return dfn[x] < dfn[y] ? x : y;
}
void init() {
auto dfs = [&](auto &&self, int x, int fa = 0) -> void {
dfn[x] = ++dfn_c;
pos[0][dfn_c] = fa;
for (auto v : G[x]) {
if (v != fa) self(self, v, x);
}
};
dfs(dfs, S);
for (int i = 1; (1 << i) <= n; ++i) {
for (int j = 1; j + (1 << i) - 1 <= n; ++j) {
pos[i][j] = get(pos[i - 1][j], pos[i - 1][j + (1 << (i - 1))]);
}
}
}
int LCA(int x, int y) {
if (x == y) return x;
x = dfn[x], y = dfn[y];
if (x > y) swap(x, y);
int k = 31 - __builtin_clz(y - x++);
return get(pos[k][x], pos[k][y - (1 << k) + 1]);
}
}
int LCA(int x, int y) {
return tree_lca::LCA(x, y);
}
vector<int> chain;
int pre[N], nxt[N];
struct Info {
int f[N], g[N], h[N], F[N], diam[N];
void init(int rt) {
auto dfs1 = [&](auto &&self, int x, int fa = 0) -> void {
for (auto v : G[x]) {
if (v == fa) continue;
self(self, v, x);
if (v != pre[x] && v != nxt[x]) {
f[x] = max(f[x], f[v] + 1);
}
}
};
dfs1(dfs1, rt);
auto dfs2 = [&](auto &&self, int x, int fa = 0, int D = 1) -> void {
h[x] = f[x] - D + 1;
for (auto v : G[x]) {
if (v != fa && (v == pre[x] || v == nxt[x])) {
g[v] = max(g[x], D + f[v]);
self(self, v, x, D + 1);
h[x] = max(h[x], h[v]);
}
}
};
dfs2(dfs2, rt);
auto dfs3 = [&](auto &&self, int x, int fa = 0, int D = 0, int ty = 0, int now = 0) -> void {
F[x] = max(now, D + f[x]);
int mx = 0, sec = 0, ind = 0;
for (auto v : G[x]) {
if (v == fa || v == pre[x] || v == nxt[x]) continue;
if (f[v] + 1 > mx) {
sec = mx, mx = f[v] + 1, ind = v;
} else {
sec = max(sec, f[v] + 1);
}
}
diam[x] = mx + sec;
for (auto v : G[x]) {
if (v == fa) continue;
int nty = ty + (v != pre[x] && v != nxt[x]), tnow = now;
if (v != pre[x] && v != nxt[x]) {
tnow = max(tnow, D + (v == ind ? mx : mx));
}
self(self, v, x, D + (nty == 1 ? 0 : (nty > 1 ? -1 : 1)), nty, tnow);
if (v != pre[x] && v != nxt[x]) {
diam[x] = max(diam[x], diam[v]);
}
}
};
dfs3(dfs3, rt);
}
} p[2];
struct Data {
int mxL, mxR, mx;
Data operator + (Data y) {
Data res;
res.mxL = max(mxL, y.mxL);
res.mxR = max(mxR, y.mxR);
res.mx = max({mx, y.mx, mxL + y.mxR});
return res;
}
} dt[1 << 20];
void build(int k, int l, int r, vector<Data> &info) {
if (l == r) {
dt[k] = info[l - 1];
return;
}
int mid = (l + r) >> 1;
build(k << 1, l, mid, info);
build(k << 1 | 1, mid + 1, r, info);
dt[k] = dt[k << 1] + dt[k << 1 | 1];
}
Data query(int k, int l, int r, int x, int y) {
if (l >= x && r <= y) return dt[k];
int mid = (l + r) >> 1;
if (y <= mid) return query(k << 1, l, mid, x, y);
if (x > mid) return query(k << 1 | 1, mid + 1, r, x, y);
return query(k << 1, l, mid, x, y) + query(k << 1 | 1, mid + 1, r, x, y);
}
void init() {
auto getFar = [&](int st) {
int mxDep = 0, wh = 0;
dep[st] = 1;
auto dfsFar = [&](auto &&self, int x, int fa = 0) -> void {
for (auto v : G[x]) {
if (v != fa) dep[v] = dep[x] + 1, self(self, v, x);
}
if (dep[x] > mxDep) {
mxDep = dep[x], wh = x;
}
};
dfsFar(dfsFar, st);
return wh;
};
S = getFar(1), T = getFar(S);
auto dfsChain = [&](auto &&self, int x) {
chain.push_back(x);
if (x == S) return;
for (auto v : G[x]) {
if (dep[v] < dep[x]) self(self, v);
}
};
dfsChain(dfsChain, T), reverse(chain.begin(), chain.end());
for (int i = 1; i < (int)chain.size(); ++i) {
pre[chain[i]] = chain[i - 1];
nxt[chain[i - 1]] = chain[i];
}
tree_lca::init();
p[0].init(S), p[1].init(T);
vector<Data> info;
for (int i = 0; i < (int)chain.size(); ++i) {
Data x;
x.mxL = p[0].f[chain[i]] + 2 * i + 2;
x.mxR = p[0].f[chain[i]] - 2 * i;
x.mx = p[0].diam[chain[i]];
info.push_back(x);
}
build(1, 1, dep[T], info);
}
int dis(int x, int y) {
return dep[x] + dep[y] - 2 * dep[LCA(x, y)];
}
int query(int x, int y) {
int a = LCA(x, T), b = LCA(y, T);
if (dep[a] > dep[b]) swap(x, y), swap(a, b);
if (dep[a] == dep[b] || dep[a] + 1 == dep[b]) {
return dep[T] - dep[S];
}
int res = dep[T] - dep[S] - (dep[b] - dep[a] - 1) * 2;
if (a != S) res = max(res, p[0].g[pre[a]]);
if (b != T) res = max(res, p[1].g[nxt[b]]);
res = max(res, p[0].h[nxt[a]] + 2 * dep[a]);
res = max(res, p[1].h[pre[b]] + 2 * (dep[S] + dep[T] - dep[b]));
res = max({res, p[0].F[x], p[1].F[y]});
res = max(res, query(1, 1, dep[T], dep[a] + 1, dep[b] - 1).mx);
return res;
}
signed main() {
int m; scanf("%d%d", &n, &m);
vector< array<int, 3> > apd;
for (int i = 1, x, y, w; i <= m; ++i) {
scanf("%d%d%d", &x, &y, &w), ++x, ++y;
if (w == 1) G[x].push_back(y), G[y].push_back(x);
else apd.push_back({x, y, w});
}
init();
int res = 2 * (n - 1) - dis(S, T);
for (auto [x, y, w] : apd) {
if (w * 2 <= n) {
int D = dis(x, y);
if (D > w) {
res = min(res, 2 * (n - 1) - D + w - query(x, y));
}
}
}
printf("%d\n", res);
return 0;
}
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 1
Accepted
time: 2ms
memory: 40260kb
input:
4 3 0 1 1 0 2 1 0 3 1
output:
4
result:
ok single line: '4'
Test #2:
score: 1
Accepted
time: 0ms
memory: 39400kb
input:
6 10 0 2 1 1 0 1 3 5 1 3 4 1 2 4 1 1 5 2 3 0 2 1 3 2 0 5 3 5 2 2
output:
5
result:
ok single line: '5'
Test #3:
score: 1
Accepted
time: 0ms
memory: 40472kb
input:
6 10 3 0 2 5 4 2 4 0 1 4 1 2 0 2 1 2 5 1 3 1 1 4 3 3 3 2 2 5 1 1
output:
5
result:
ok single line: '5'
Test #4:
score: 1
Accepted
time: 0ms
memory: 38180kb
input:
6 10 0 1 1 5 0 1 4 1 1 5 2 3 1 3 1 2 0 2 2 3 1 4 5 2 2 4 2 5 3 2
output:
6
result:
ok single line: '6'
Test #5:
score: 1
Accepted
time: 1ms
memory: 40008kb
input:
6 10 0 5 2 1 5 2 2 1 1 1 0 1 3 4 3 4 1 1 3 5 2 5 2 1 3 1 1 5 4 2
output:
7
result:
ok single line: '7'
Test #6:
score: 1
Accepted
time: 0ms
memory: 41120kb
input:
6 10 1 2 1 2 3 2 3 1 1 4 5 6 5 3 4 1 5 1 0 4 3 0 3 3 0 1 1 1 4 1
output:
8
result:
ok single line: '8'
Test #7:
score: 1
Accepted
time: 4ms
memory: 41008kb
input:
6 10 2 5 3 2 4 2 2 0 2 4 3 1 4 0 3 2 1 3 3 5 1 2 3 1 1 3 1 0 3 1
output:
8
result:
ok single line: '8'
Test #8:
score: 1
Accepted
time: 2ms
memory: 40900kb
input:
6 10 5 1 2 0 1 2 0 5 1 2 4 1 3 1 1 2 3 2 3 0 2 4 1 1 5 2 1 5 3 2
output:
5
result:
ok single line: '5'
Test #9:
score: 1
Accepted
time: 0ms
memory: 40980kb
input:
6 10 2 1 2 0 2 1 4 2 1 3 1 1 5 0 1 1 5 1 3 4 3 3 0 2 2 3 2 1 4 2
output:
5
result:
ok single line: '5'
Test #10:
score: 1
Accepted
time: 0ms
memory: 41740kb
input:
6 10 2 3 1 0 3 2 2 1 2 4 5 2 4 1 1 2 5 1 0 5 1 0 4 2 3 4 1 0 1 3
output:
5
result:
ok single line: '5'
Test #11:
score: 1
Accepted
time: 1ms
memory: 40072kb
input:
6 10 0 1 2 1 4 2 1 5 2 0 4 1 5 0 1 5 3 2 2 3 1 0 2 1 2 1 1 5 4 5
output:
6
result:
ok single line: '6'
Test #12:
score: 1
Accepted
time: 2ms
memory: 40012kb
input:
6 10 2 0 2 5 1 1 0 3 2 2 3 2 5 0 5 3 4 1 5 2 1 5 3 2 0 1 1 4 5 1
output:
6
result:
ok single line: '6'
Test #13:
score: 1
Accepted
time: 1ms
memory: 40352kb
input:
6 10 4 2 1 1 5 1 5 0 1 0 3 2 3 5 2 0 4 2 2 5 1 3 2 1 2 0 6 4 3 5
output:
6
result:
ok single line: '6'
Test #14:
score: 0
Wrong Answer
time: 0ms
memory: 40948kb
input:
6 6 1 5 1 5 0 1 3 1 2 3 2 1 4 2 1 2 5 1
output:
7
result:
wrong answer 1st lines differ - expected: '6', found: '7'
Subtask #2:
score: 0
Wrong Answer
Test #16:
score: 2
Accepted
time: 2ms
memory: 43592kb
input:
9 10 0 1 1 0 2 1 0 3 1 1 4 1 2 5 1 2 6 1 3 7 1 3 8 1 2 4 5 6 7 3
output:
11
result:
ok single line: '11'
Test #17:
score: 2
Accepted
time: 2ms
memory: 41952kb
input:
9 9 0 1 1 1 2 1 2 3 1 3 4 1 2 5 1 5 6 1 2 7 1 7 8 1 4 6 3
output:
11
result:
ok single line: '11'
Test #18:
score: 2
Accepted
time: 0ms
memory: 43704kb
input:
12 12 9 0 1 0 1 1 1 11 1 11 2 1 2 3 1 3 4 1 4 10 1 2 5 1 5 6 1 11 7 1 7 8 1 10 6 4
output:
15
result:
ok single line: '15'
Test #19:
score: 2
Accepted
time: 2ms
memory: 43684kb
input:
15 14 9 0 1 0 1 1 1 11 1 11 14 1 14 2 1 2 3 1 3 4 1 4 10 1 2 5 1 5 6 1 6 12 1 11 7 1 7 8 1 8 13 1
output:
20
result:
ok single line: '20'
Test #20:
score: 0
Wrong Answer
time: 0ms
memory: 42108kb
input:
15 15 9 0 1 0 1 1 1 11 1 11 14 1 14 2 1 2 3 1 3 4 1 4 10 1 2 5 1 5 6 1 6 12 1 11 7 1 7 8 1 8 13 1 10 12 5
output:
19
result:
wrong answer 1st lines differ - expected: '20', found: '19'
Subtask #3:
score: 2
Accepted
Test #35:
score: 2
Accepted
time: 2ms
memory: 63068kb
input:
5000 10000 1867 4363 2515 262 989 2506 22 808 1 3969 1940 1 301 4586 2912 2193 1408 1 2656 3426 2589 643 4376 2570 4986 4031 1 2149 538 2636 1662 183 2518 3111 3252 2885 3710 216 2679 4540 11 1 4690 3663 1 3549 4010 2666 2480 3321 1 216 15 2530 1228 3212 2965 1923 1417 2724 3832 1842 2649 3937 1191 ...
output:
4999
result:
ok single line: '4999'
Test #36:
score: 2
Accepted
time: 5ms
memory: 61288kb
input:
4999 10000 1811 2026 2694 3479 3673 2663 1418 2998 2511 1533 746 1 3141 2435 1 8 3832 1 3350 4951 1 3866 1685 1 3174 803 1 4859 2198 3111 2532 3104 1 360 2983 3434 4810 661 1 3196 3277 1 3766 4511 1 4665 38 1 3829 3722 1 3669 3100 1 3779 3560 3109 2532 257 1 4494 1302 3212 2300 4182 1 1122 2796 1 41...
output:
4998
result:
ok single line: '4998'
Test #37:
score: 2
Accepted
time: 3ms
memory: 62796kb
input:
4999 10000 4535 296 2529 4754 1564 2631 4255 1701 1 4776 1038 1 4180 3807 2633 2924 1082 2508 372 51 2899 2041 2754 2524 1976 3391 2563 4103 4955 2566 419 840 1 355 1999 2504 3726 2488 2587 728 836 1 355 97 2501 2852 1901 2503 4034 2911 1 2202 2453 1 3239 327 2778 436 686 1 2370 1022 2514 3866 3929 ...
output:
6664
result:
ok single line: '6664'
Test #38:
score: 2
Accepted
time: 2ms
memory: 60356kb
input:
4998 10000 4160 4537 1 3358 2521 1 2897 4536 1 2004 3684 1 543 139 3825 641 1841 3630 4934 3527 3118 144 2651 1 2185 3663 1 3382 2931 1 1095 3978 1 3934 1384 3439 3777 1089 2697 4732 591 3854 717 4222 3394 88 1043 1 1606 1970 1 2491 2131 2813 4924 1126 2662 1001 440 3886 369 1061 1 2667 2847 1 4975 ...
output:
7495
result:
ok single line: '7495'
Test #39:
score: 2
Accepted
time: 5ms
memory: 60428kb
input:
4998 10000 2997 3161 1 3664 4692 2648 3671 4617 1 1427 3471 1 3455 3660 2810 3979 2418 1 4606 471 1 1809 3050 2728 1531 3037 1 2254 4415 1 2445 1898 1 2772 3275 1 2729 204 4604 1485 1625 4570 971 3747 4039 2616 1632 3080 4925 3300 1 4045 4637 4115 456 4869 1 2662 4208 1 745 195 1 2497 1663 1 669 651...
output:
7994
result:
ok single line: '7994'
Test #40:
score: 2
Accepted
time: 4ms
memory: 60876kb
input:
5000 10000 3294 692 1 3294 883 1 3294 57 1 3294 3972 1 3294 3107 1 13 3294 1 4039 4508 2813 4074 4356 4511 760 3294 1 3294 215 1 2281 834 3509 1861 2733 2852 1716 2215 3549 640 3294 1 3294 2215 1 4044 3628 3386 3294 4396 1 2276 3599 3982 1855 2120 3761 4620 2792 2622 259 4461 3361 3294 1794 1 2792 1...
output:
9996
result:
ok single line: '9996'
Test #41:
score: 2
Accepted
time: 7ms
memory: 58848kb
input:
4998 10000 2037 3029 2962 3529 1776 3256 4052 2853 3389 130 1776 3070 3630 2951 1 4846 4531 1 2204 1792 2814 3532 2181 3077 2070 1549 2825 630 2837 1 1172 525 2657 1503 346 1 2772 2432 1 4351 3852 1 991 3154 1 4161 3636 1 1533 3782 1 3839 0 3253 4107 1724 1 2371 441 1 2490 1476 2514 1344 4103 1 1101...
output:
5002
result:
ok single line: '5002'
Test #42:
score: 2
Accepted
time: 2ms
memory: 59624kb
input:
4998 10000 3604 2415 2552 2999 4014 1 2138 3572 2677 4902 1482 1 2339 217 1 638 1323 2662 3600 2998 2506 231 2582 2707 2491 4955 2625 1746 4277 2541 3886 4104 2525 506 1917 2808 4810 3721 1 4841 4081 2551 3925 4360 1 3754 572 1 2777 848 1 4582 864 1 149 2112 2518 2848 1445 1 2681 3254 1 4412 2967 1 ...
output:
6776
result:
ok single line: '6776'
Test #43:
score: 2
Accepted
time: 7ms
memory: 62500kb
input:
4998 10000 1996 2117 3222 4177 4126 3634 1011 1208 2930 2923 3872 2536 4677 2176 1 1239 3704 2689 2726 1986 3364 2985 3118 3279 2271 864 2864 2811 3508 2633 3823 1193 3210 1880 4435 1 867 3420 2632 3687 2910 2730 2020 1769 1 751 2339 1 3410 3910 1 4518 342 2872 1720 1404 1 4945 393 1 4904 4175 1 224...
output:
5593
result:
ok single line: '5593'
Test #44:
score: 2
Accepted
time: 6ms
memory: 60612kb
input:
4998 10000 4804 28 3849 721 2739 2696 1788 1153 1 1598 2007 4146 1345 473 1 1248 1922 2542 517 181 1 4284 3809 2836 860 2718 1 4738 4912 1 2821 4331 1 2375 10 1 2943 2609 3226 3904 389 1 3526 4773 1 2682 1300 1 3221 4571 1 2174 2709 1 1695 2472 3412 3958 480 2568 504 1749 3134 2926 2134 3838 2429 18...
output:
7495
result:
ok single line: '7495'
Test #45:
score: 2
Accepted
time: 3ms
memory: 60120kb
input:
4995 10000 4894 4404 1 2663 3250 3525 1794 3573 3400 4352 2925 2570 4816 3505 2629 4661 613 2539 3418 1376 1 1745 1017 2603 1169 347 1 3945 2997 1 879 1344 3492 4133 2070 1 2116 3625 1 3067 4194 2529 4804 2777 3108 724 879 1 3508 961 1 3708 3515 4459 869 557 1 44 1412 1 4587 2950 3157 1307 2506 1 30...
output:
6662
result:
ok single line: '6662'
Test #46:
score: 2
Accepted
time: 2ms
memory: 60064kb
input:
4989 10000 308 3531 2495 3166 214 1 1550 4139 1 75 3098 1 4700 3912 2495 2472 4255 1 1380 72 1 4375 3042 1 2030 4261 2495 4180 3405 2495 2319 2501 1 1492 3741 1 81 187 1 1327 4535 2495 3405 1851 2495 3515 342 1 2043 3674 1 1680 314 1 3405 2295 2495 1802 349 2495 2366 1840 2495 349 3442 2495 4149 471...
output:
7482
result:
ok single line: '7482'
Test #47:
score: 2
Accepted
time: 7ms
memory: 60220kb
input:
4995 10000 1724 2508 2874 3718 883 2875 1904 2406 1 4855 4627 1 4863 2837 3750 1486 3234 2687 2590 991 3054 3973 1844 3072 2746 2554 1 1093 1639 1 2472 3348 2892 3552 4957 2597 4871 2257 1 2536 4347 3340 4160 1715 4061 930 821 1 645 2536 3428 526 468 3190 4391 3086 4118 712 1277 3042 3277 3971 1 385...
output:
6662
result:
ok single line: '6662'
Test #48:
score: 2
Accepted
time: 4ms
memory: 59804kb
input:
4995 10000 3624 3363 2859 668 4378 2564 488 2100 2994 814 645 3044 3264 3878 2525 3723 2062 1 2701 4514 1 1175 9 1 4659 789 3293 4185 144 1 4898 4832 3146 3360 2869 2505 737 2906 1 2244 2587 1 1540 4658 3620 1803 1598 1 4369 3944 1 38 340 3773 4619 2493 1 1656 4768 3059 3037 2314 1 3890 4371 2647 15...
output:
6662
result:
ok single line: '6662'
Subtask #4:
score: 0
Wrong Answer
Test #49:
score: 6
Accepted
time: 1ms
memory: 46924kb
input:
100 200 98 79 1 40 18 1 45 56 1 23 26 39 88 51 1 49 31 35 55 85 1 5 71 35 88 38 36 30 90 38 73 90 39 83 65 1 80 18 35 91 27 35 39 66 1 96 23 34 30 40 36 60 41 1 78 22 1 25 97 42 98 40 43 33 7 35 58 13 1 7 84 1 4 16 70 88 99 1 24 36 1 40 26 37 30 79 1 27 44 1 44 12 42 84 37 54 50 69 35 18 89 1 93 29 ...
output:
99
result:
ok single line: '99'
Test #50:
score: 6
Accepted
time: 3ms
memory: 46332kb
input:
99 200 47 6 34 5 83 1 22 66 1 40 8 1 17 73 42 52 98 40 80 74 75 82 94 45 35 74 1 32 48 1 75 26 55 59 87 1 14 60 37 68 76 62 30 45 46 56 21 1 74 83 74 68 60 35 40 74 1 68 79 41 10 78 1 16 76 51 85 60 60 33 8 45 70 0 1 86 83 49 3 20 1 3 36 1 86 38 33 9 52 45 15 38 33 93 0 1 93 82 1 98 37 60 50 18 1 33...
output:
98
result:
ok single line: '98'
Test #51:
score: 0
Wrong Answer
time: 1ms
memory: 46640kb
input:
100 200 86 2 1 20 32 1 3 16 1 71 28 52 90 70 1 24 74 1 70 51 34 67 38 48 45 28 38 55 44 1 22 65 38 97 27 37 18 69 1 13 49 1 84 99 1 60 4 39 78 56 1 47 79 1 48 68 40 31 29 1 82 51 40 82 74 41 22 44 35 21 67 35 45 86 51 25 21 36 12 24 53 81 26 1 69 75 1 70 33 1 36 2 36 20 62 1 65 45 35 91 41 1 21 60 4...
output:
101
result:
wrong answer 1st lines differ - expected: '132', found: '101'
Subtask #5:
score: 0
Wrong Answer
Test #63:
score: 2
Accepted
time: 4ms
memory: 52228kb
input:
500 1000 208 211 175 291 249 178 221 407 234 95 379 1 455 400 1 28 217 1 488 93 1 398 101 191 382 222 184 407 77 191 183 471 1 306 466 1 174 78 175 391 180 167 432 486 1 414 284 171 436 446 1 34 294 1 38 110 1 41 186 1 148 336 1 85 33 1 491 114 171 22 197 1 385 388 183 245 41 176 423 257 1 100 203 1...
output:
499
result:
ok single line: '499'
Test #64:
score: 2
Accepted
time: 3ms
memory: 54192kb
input:
499 1000 129 32 1 83 112 369 275 120 1 123 382 168 316 326 244 238 349 257 7 103 207 21 468 319 479 269 1 156 66 1 312 351 1 80 299 1 413 306 1 155 240 1 306 87 305 67 188 188 481 271 230 122 77 1 285 491 1 120 247 288 454 158 1 12 459 1 447 139 1 429 399 308 217 200 1 87 468 195 93 81 1 405 165 187...
output:
498
result:
ok single line: '498'
Test #65:
score: 0
Wrong Answer
time: 1ms
memory: 53892kb
input:
499 1000 179 207 191 269 207 167 454 87 1 258 456 1 267 19 1 400 387 1 261 326 1 383 246 219 193 388 198 219 278 173 476 71 1 331 289 1 36 427 194 152 285 221 352 419 1 325 5 1 104 89 1 67 279 178 445 300 1 486 280 201 414 486 231 339 435 1 346 21 1 384 3 1 369 362 1 297 416 1 498 408 1 55 374 1 460...
output:
502
result:
wrong answer 1st lines differ - expected: '664', found: '502'
Subtask #6:
score: 0
Wrong Answer
Test #77:
score: 3
Accepted
time: 3ms
memory: 59900kb
input:
5000 10000 1233 3822 1672 230 3287 1 3304 542 1 4203 4319 1 3890 46 1 1145 4330 1865 4631 4227 1667 3806 541 1 3145 196 1846 2583 4656 1 2526 3928 1 1339 2914 1 448 438 1945 3691 4076 2605 2115 2224 1727 3050 4573 1876 334 4820 1725 4792 2439 1 279 787 1 3592 4602 1704 3634 3783 1 4822 424 1687 1546...
output:
4999
result:
ok single line: '4999'
Test #78:
score: 3
Accepted
time: 5ms
memory: 62568kb
input:
4999 10000 1536 2256 2503 1838 4182 1 4242 4573 1 4453 4031 2797 4843 4842 2784 701 2457 1906 1106 324 2586 4432 424 3795 496 930 2340 2468 1024 1 2922 4574 1882 1640 4939 1 2452 2963 1 1659 308 1 346 1011 1 2490 2062 1 3519 664 1 1252 1603 1 1095 737 1 3444 573 1 4448 1092 1 262 4248 3240 4244 1059...
output:
4998
result:
ok single line: '4998'
Test #79:
score: 0
Wrong Answer
time: 5ms
memory: 61096kb
input:
4999 10000 1756 464 1 2256 3527 1779 3158 662 1979 648 4209 1 131 4844 2373 4768 1977 1 4338 2206 1 3900 1283 1764 3656 4458 1 642 1292 1 3377 1257 1734 3228 4789 1 2418 3295 2112 4489 3040 1947 4604 4945 2171 1761 4027 1 1770 88 1 4217 1453 1 4732 4196 2069 2042 2568 1 172 286 2163 1578 4021 2125 1...
output:
5071
result:
wrong answer 1st lines differ - expected: '6664', found: '5071'
Subtask #7:
score: 0
Wrong Answer
Test #91:
score: 5
Accepted
time: 87ms
memory: 80112kb
input:
79998 160000 47319 43920 27006 37874 58542 1 2314 12853 1 36506 22858 26740 68911 13350 31720 25597 38100 1 64407 54997 1 51674 45889 26896 6348 21021 1 20123 37354 1 40529 9510 1 17862 77380 1 33670 44212 1 49850 17554 1 66696 36952 26977 68826 79479 1 57060 12489 1 5752 45575 1 7053 19904 26742 66...
output:
106662
result:
ok single line: '106662'
Test #92:
score: 5
Accepted
time: 94ms
memory: 81720kb
input:
79995 160000 61320 66228 31633 20416 6828 26745 65430 51513 28853 61601 77927 1 33775 10749 30386 33489 57662 28107 65564 42605 1 72503 58487 28031 24791 62445 1 361 36744 31994 6993 12131 1 38636 9267 30756 50189 3424 27481 21764 13079 27045 13091 75180 1 76213 1089 29713 29054 60322 28242 6840 342...
output:
106661
result:
ok single line: '106661'
Test #93:
score: 5
Accepted
time: 86ms
memory: 80224kb
input:
79989 160000 32970 17371 1 51500 77845 1 8694 39321 1 33402 55053 1 3593 13400 1 25018 73843 1 10116 78323 39829 12333 8162 1 77825 52478 39800 71287 49773 39857 69284 34436 1 58422 323 1 71978 34401 1 32727 4966 39931 17840 59434 1 78584 5862 1 33173 8137 39835 35430 76217 1 77630 21975 1 39606 180...
output:
119980
result:
ok single line: '119980'
Test #94:
score: 5
Accepted
time: 72ms
memory: 78276kb
input:
79998 93330 39579 27063 1 48572 35446 1 40362 9364 28215 28842 18275 1 71735 67469 1 76515 33620 1 30996 48788 1 14552 9364 36309 77625 2707 1 1342 19383 1 5882 66210 1 73150 46423 1 75551 4187 1 43266 70746 1 71784 32162 1 79762 69551 1 48566 46786 1 9364 34906 38002 21007 73310 1 39475 66834 1 375...
output:
119994
result:
ok single line: '119994'
Test #95:
score: 5
Accepted
time: 75ms
memory: 78300kb
input:
79998 93330 6540 36912 1 6828 67666 1 64532 68447 1 71308 47069 1 28144 17430 1 74171 26737 1 37891 59511 38136 13928 72394 1 10800 18697 1 78179 63555 1 58591 59292 1 68147 62982 1 35098 75561 1 18417 43389 1 26115 70392 1 43212 11367 1 34505 67384 1 13934 74906 1 13688 59511 31890 47362 59511 2850...
output:
119994
result:
ok single line: '119994'
Test #96:
score: 5
Accepted
time: 120ms
memory: 87124kb
input:
80000 160000 18646 25309 31117 75880 22684 26801 9589 30212 28588 75855 59124 26759 39977 32801 1 33356 51569 1 32561 7906 28071 50960 76844 31594 67 53601 1 33104 4508 1 77268 6010 26897 78324 71277 1 60358 32572 27870 6192 39931 33107 47020 32401 37620 7263 48001 1 66559 43096 27554 40677 31787 1 ...
output:
79999
result:
ok single line: '79999'
Test #97:
score: 5
Accepted
time: 102ms
memory: 87328kb
input:
79999 160000 24942 30968 1 52955 71005 26826 46890 43341 1 18100 66202 1 68417 13241 1 66471 79814 27146 74673 44182 1 7913 53962 29100 25698 9147 1 39604 48948 30410 71267 8338 1 53847 54500 1 67757 40624 32934 44367 72934 1 53487 28998 1 31093 66648 1 40690 3748 30034 26240 75595 29035 10172 42680...
output:
79998
result:
ok single line: '79998'
Test #98:
score: 0
Wrong Answer
time: 97ms
memory: 83752kb
input:
79999 160000 68371 12363 1 66033 66837 1 54751 63697 1 47334 55960 1 42742 12344 1 26282 22385 1 4354 70183 1 64445 16533 28453 29298 79678 33046 9031 16502 33273 11898 10444 31740 42661 63249 32839 54569 42878 1 26197 16893 1 36502 29265 1 70474 72121 1 26016 60327 27238 33290 10560 1 14981 36785 1...
output:
80384
result:
wrong answer 1st lines differ - expected: '106664', found: '80384'
Subtask #8:
score: 0
Wrong Answer
Test #105:
score: 4
Accepted
time: 1878ms
memory: 191660kb
input:
500000 2000000 492952 221541 267388 189147 466806 1 176713 26739 184225 184178 191476 193886 268077 21780 170551 226184 221541 302897 9942 461890 1 221541 343066 171790 495977 267797 176982 213497 330126 205211 128338 411248 1 283722 405246 217711 18538 208366 1 164175 376442 254213 29263 221541 171...
output:
499999
result:
ok single line: '499999'
Test #106:
score: 4
Accepted
time: 2002ms
memory: 193632kb
input:
499999 2000000 338233 340347 226535 38717 379987 168389 336194 116029 1 177994 341315 1 324318 325023 189015 407991 59970 1 363275 468224 1 20980 497440 167304 173157 482862 194272 268329 191991 167875 493110 59848 176331 167640 301032 1 38980 608 1 451792 351819 1 466507 16056 313310 159434 426922 ...
output:
499998
result:
ok single line: '499998'
Test #107:
score: 0
Wrong Answer
time: 1892ms
memory: 174084kb
input:
499999 2000000 225504 367124 184692 13152 368884 1 246115 310825 1 85546 260802 1 36120 263251 1 347061 457515 179247 391512 418943 209628 488000 251230 202554 342387 451505 218204 250597 6360 1 314794 356575 167579 379921 169405 175694 238333 100765 213326 23010 256301 1 138786 206212 195538 119086...
output:
500362
result:
wrong answer 1st lines differ - expected: '666664', found: '500362'