QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#641863 | #215. Podatki drogowe [A] | Elegia | 10 ✓ | 4452ms | 178860kb | C++23 | 7.5kb | 2024-10-15 02:55:40 | 2024-10-15 02:55:40 |
Judging History
answer
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>
#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>
#define LOG(FMT...) fprintf(stderr, FMT)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#ifdef LBT
mt19937_64 rng(20030811);
#else
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#endif
template <class T>
istream& operator>>(istream& is, vector<T>& v) {
for (T& x : v)
is >> x;
return is;
}
template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
if (!v.empty()) {
os << v.front();
for (int i = 1; i < v.size(); ++i)
os << ' ' << v[i];
}
return os;
}
const int N = 25010, L = 20, Djq = 1000000007;
int norm(int x) { return x >= Djq ? x - Djq : x; }
int Base;
struct Node {
Node *ls, *rs;
int hsh;
};
int n;
Node pool[N * L * L], *top = pool;
int pwBase[N], tmp[N];
Node* build(int l, int r) {
Node* o = top++;
if (l == r) {
o->hsh = tmp[l];
return o;
}
int mid = (l + r) >> 1;
o->ls = build(l, mid);
o->rs = build(mid + 1, r);
o->hsh = (o->ls->hsh * (ll)pwBase[r - mid] + o->rs->hsh) % Djq;
return o;
}
Node* change(const Node* p, int l, int r, int k, int v) {
Node* o = top++;
if (l == r)
o->hsh = p->hsh + v;
else {
int mid = (l + r) >> 1;
o->ls = k <= mid ? change(p->ls, l, mid, k, v) : p->ls;
o->rs = k > mid ? change(p->rs, mid + 1, r, k, v) : p->rs;
o->hsh = (o->ls->hsh * (ll)pwBase[r - mid] + o->rs->hsh) % Djq;
}
return o;
}
// suppose x->hsh != y->hsh
int cmp(const Node* x, const Node* y, int l, int r) {
if (l == r) return x->hsh < y->hsh ? -1 : 1;
int mid = (l + r) >> 1;
return x->rs->hsh == y->rs->hsh ? cmp(x->ls, y->ls, l, mid) : cmp(x->rs, y->rs, mid + 1, r);
}
int sumcmp(const Node* x, const Node* y, const Node* z, int l, int r) {
if (norm(x->hsh + y->hsh) == z->hsh) return 0;
if (l == r)
return (x->hsh + y->hsh) < z->hsh ? -1 : 1;
int mid = (l + r) >> 1;
int o = sumcmp(x->rs, y->rs, z->rs, mid + 1, r);
return o ? o : sumcmp(x->ls, y->ls, z->ls, l, mid);
}
void getv(const Node* o, int l, int r) {
if (l == r) {
tmp[l] += o->hsh;
return;
}
int mid = (l + r) >> 1;
getv(o->ls, l, mid);
getv(o->rs, mid + 1, r);
}
struct PInt {
Node* rt;
PInt() {}
PInt(Node *rt) : rt(rt) {}
int getDigit(int k) const {
int l = 1, r = n;
const Node* o = rt;
while (l != r) {
int mid = (l + r) >> 1;
if (k <= mid) {
r = mid;
o = o->ls;
} else {
l = mid + 1;
o = o->rs;
}
}
return o->hsh;
}
PInt change(int k, int x) const {
return PInt(::change(rt, 1, n, k, x));
}
bool operator<(const PInt& rhs) const {
if (rt->hsh == rhs.rt->hsh) return false;
return cmp(rt, rhs.rt, 1, n) < 0;
}
bool operator==(const PInt& rhs) const {
return rt->hsh == rhs.rt->hsh;
}
};
// cmp(x + y, z)
int sumcmp(const PInt& x, const PInt& y, const PInt& z) { return sumcmp(x.rt, y.rt, z.rt, 1, n); }
PInt PZero, PInf;
vector<pair<int, int>> g[N];
vector<PInt> mL[N * 2], mR[N * 2];
vector<pair<int, int>> range[N * 2];
int curSz;
bool vis[N];
int sz[N];
int main() {
#ifdef LBT
freopen("test.in", "r", stdin);
int nol_cl = clock();
#endif
ios::sync_with_stdio(false);
cin.tie(nullptr);
ll k;
cin >> n >> k;
for (int rep = 1; rep < n; ++rep) {
int u, v, w;
cin >> u >> v >> w;
g[u].emplace_back(v, w);
g[v].emplace_back(u, w);
}
Base = rng() % (Djq - n * 4) + n * 2;
pwBase[0] = 1;
for (int i = 1; i <= n; ++i) pwBase[i] = pwBase[i - 1] * (ll)Base % Djq;
PZero = PInt(build(1, n));
fill(tmp + 1, tmp + n + 1, n);
PInf = PInt(build(1, n));
function<void(int, int)> dfs = [&](int u, int p) {
sz[u] = 1;
for (auto [v, ignore] : g[u])
if (v != p && !vis[v]) {
dfs(v, u);
sz[u] += sz[v];
}
if (p == -1) curSz = sz[u];
};
function<int(int, int)> centroid = [&](int u, int p) {
for (auto [v, ignore] : g[u])
if (v != p && !vis[v] && (sz[v] << 1) > curSz)
return centroid(v, u);
return u;
};
vector<PInt> cur;
function<void(int, int, const PInt&)> dfs2 = [&](int u, int p, const PInt& dis) {
cur.push_back(dis);
for (auto [v, w] : g[u])
if (!vis[v] && v != p)
dfs2(v, u, dis.change(w, 1));
};
priority_queue<vector<PInt>, vector<vector<PInt>>, function<bool(const vector<PInt> &, const vector<PInt> &)>> q(
[&](const vector<PInt> &lhs, const vector<PInt> &rhs) { return lhs.size() > rhs.size(); });
int m = 0;
function<void(int)> solve = [&](int u) {
dfs(u, -1);
u = centroid(u, -1);
vis[u] = true;
q.push({PZero});
for (auto [v, w] : g[u])
if (!vis[v]) {
dfs2(v, u, PZero.change(w, 1));
stable_sort(cur.begin(), cur.end());
q.push(cur);
cur.clear();
}
while (q.size() > 1) {
vector<PInt> vL = q.top(); q.pop();
vector<PInt> vR = q.top(); q.pop();
mL[++m] = vL;
mR[m] = vR;
range[m].resize(vL.size());
vector<PInt> mg;
mg.reserve(vL.size() + vR.size());
merge(vL.begin(), vL.end(), vR.begin(), vR.end(), back_inserter(mg));
q.push(mg);
}
q.pop();
for (auto [v, ignore] : g[u])
if (!vis[v])
solve(v);
};
solve(1);
PInt low = PZero, high = PInf;
ll lowC = 0, highC = n * (n - 1LL) / 2 + 1;
ll to = 0;
for (int i = 1; i <= m; ++i) {
to += mL[i].size() * mR[i].size();
}
while (lowC < k && k < highC) {
uniform_int_distribution<ll> uid(0, highC - lowC - 2);
ll kth = uid(rng);
PInt pivot;
for (int i = 1; i <= m; ++i) {
int pL = 0, pR = 0;
for (int j = (int)mL[i].size() - 1; j >= 0; --j) {
while (pL != mR[i].size() && sumcmp(mL[i][j], mR[i][pL], low) <= 0) ++pL;
while (pR != mR[i].size() && sumcmp(mL[i][j], mR[i][pR], high) < 0) ++pR;
range[i][j] = make_pair(pL, pR);
}
}
for (int i = 1; i <= m; ++i) {
for (int j = (int)mL[i].size() - 1; j >= 0; --j) {
int len = range[i][j].second - range[i][j].first;
if (len > kth) {
memset(tmp, 0, sizeof(tmp));
getv(mL[i][j].rt, 1, n);
getv(mR[i][range[i][j].first + kth].rt, 1, n);
pivot = build(1, n);
kth = -1; break;
}
kth -= len;
}
if (kth < 0) break;
}
ll rL = 1, rR = 0;
for (int i = 1; i <= m; ++i) {
int pL = 0, pR = 0;
for (int j = (int)mL[i].size() - 1; j >= 0; --j) {
while (pL != mR[i].size() && sumcmp(mL[i][j], mR[i][pL], pivot) < 0) ++pL;
while (pR != mR[i].size() && sumcmp(mL[i][j], mR[i][pR], pivot) <= 0) ++pR;
rL += pL;
rR += pR;
}
}
if (rL > k) {
high = pivot;
highC = rL;
} else {
low = pivot;
lowC = rR;
}
}
memset(tmp, 0, sizeof(tmp));
getv(k <= lowC ? low.rt : high.rt, 1, n);
int ans = 0;
for (int i = n; i >= 0; --i) ans = (ans * (ll)n + tmp[i]) % Djq;
cout << ans << '\n';
#ifdef LBT
LOG("Time: %dms\n", int ((clock()
-nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
return 0;
}
詳細信息
Subtask #1:
score: 1
Accepted
Test #1:
score: 1
Accepted
time: 1ms
memory: 5724kb
input:
2 1 1 2 1
output:
2
result:
ok single line: '2'
Test #2:
score: 1
Accepted
time: 1ms
memory: 3776kb
input:
4 1 1 4 4 3 1 4 2 3 4
output:
256
result:
ok single line: '256'
Test #3:
score: 1
Accepted
time: 1ms
memory: 3800kb
input:
16 38 1 10 3 6 8 1 8 10 1 1 4 12 16 14 8 9 3 6 12 7 7 11 2 14 13 14 7 16 8 13 2 15 9 7 16 4 5 15 15 16 15 7 3 10 13
output:
595845335
result:
ok single line: '595845335'
Test #4:
score: 1
Accepted
time: 2ms
memory: 5700kb
input:
64 145 10 61 12 8 54 28 46 43 17 35 57 50 3 43 9 44 4 55 46 58 64 5 46 35 14 58 49 9 14 15 4 38 48 34 57 50 42 19 27 38 22 16 4 34 44 12 48 31 36 47 28 39 34 64 29 45 6 32 40 58 5 64 2 1 55 25 29 18 40 31 15 16 46 24 22 50 62 46 11 21 23 24 42 63 36 5 30 49 50 37 41 44 35 26 2 4 12 46 18 42 10 61 55...
output:
905866555
result:
ok single line: '905866555'
Test #5:
score: 1
Accepted
time: 5ms
memory: 5772kb
input:
197 10302 148 35 124 68 13 83 41 168 178 46 62 16 126 26 106 104 94 78 151 125 127 69 110 75 119 187 93 24 27 136 49 138 135 107 39 8 185 60 69 65 155 194 166 17 13 61 97 86 174 28 31 170 190 150 100 74 113 90 8 1 177 6 40 39 113 84 85 129 81 19 64 148 9 190 85 163 74 10 53 140 40 171 54 82 180 91 1...
output:
278287289
result:
ok single line: '278287289'
Test #6:
score: 1
Accepted
time: 3ms
memory: 4284kb
input:
199 1 167 27 110 52 136 24 90 66 57 30 110 78 37 143 87 169 94 151 18 115 43 158 86 75 115 168 122 191 76 31 29 195 86 101 137 53 83 164 119 101 177 67 132 25 183 89 93 59 62 32 71 19 102 1 170 60 4 169 153 14 158 195 127 151 53 53 159 121 8 6 56 41 174 8 165 192 190 122 174 16 67 48 119 52 171 22 4...
output:
199
result:
ok single line: '199'
Test #7:
score: 1
Accepted
time: 3ms
memory: 4128kb
input:
198 19503 147 180 173 151 145 6 146 59 48 89 81 22 2 162 72 22 135 198 91 198 142 53 127 126 99 167 112 90 20 22 73 8 157 54 152 57 45 19 71 8 156 19 5 22 82 160 60 4 155 72 146 180 159 148 57 55 153 127 15 49 65 92 108 104 137 16 163 46 138 83 16 192 89 119 67 177 82 53 126 196 8 185 105 167 78 14 ...
output:
577262621
result:
ok single line: '577262621'
Test #8:
score: 1
Accepted
time: 3ms
memory: 4220kb
input:
200 9934 114 125 93 174 84 162 158 148 74 34 138 54 70 118 43 89 25 91 11 118 10 194 113 79 4 92 197 110 103 58 60 73 88 37 13 153 40 198 44 21 128 30 181 182 174 196 143 90 56 100 76 69 93 83 169 26 4 86 183 63 111 159 179 78 154 64 165 179 183 62 19 181 161 94 109 122 178 14 41 88 177 88 54 111 43...
output:
20671845
result:
ok single line: '20671845'
Test #9:
score: 1
Accepted
time: 4ms
memory: 4304kb
input:
197 16063 123 121 119 88 93 119 20 94 76 121 185 71 83 92 194 80 154 95 22 97 29 92 114 151 135 78 102 50 178 183 174 168 115 27 46 151 106 152 123 79 119 2 180 171 141 166 98 53 74 125 139 64 11 80 115 35 39 104 145 40 38 109 94 163 179 27 157 32 195 51 73 50 194 155 84 120 131 127 84 65 44 103 157...
output:
526336499
result:
ok single line: '526336499'
Test #10:
score: 1
Accepted
time: 5ms
memory: 5792kb
input:
199 7023 30 181 72 85 27 128 129 140 37 84 34 92 123 186 58 22 164 82 144 154 38 22 174 97 142 32 162 134 131 151 12 170 54 156 46 118 5 179 177 99 147 143 143 176 91 80 180 85 53 70 35 85 105 192 29 45 76 120 191 54 33 159 10 189 163 21 14 128 161 15 136 168 54 49 13 96 182 136 54 28 6 199 131 142 ...
output:
757541705
result:
ok single line: '757541705'
Test #11:
score: 1
Accepted
time: 4ms
memory: 4164kb
input:
197 5602 19 65 43 83 89 16 142 155 13 78 43 13 36 170 8 76 184 33 106 85 58 192 147 32 130 90 4 7 91 16 142 146 12 176 27 48 154 70 39 133 73 23 125 92 36 56 43 12 179 196 24 139 36 9 172 34 38 23 108 54 85 164 57 161 181 64 126 32 13 52 26 43 139 152 10 67 167 10 94 97 5 39 75 56 14 57 49 197 112 6...
output:
534273792
result:
ok single line: '534273792'
Test #12:
score: 1
Accepted
time: 2ms
memory: 5764kb
input:
198 17487 190 78 1 44 28 1 193 118 1 76 71 1 129 120 1 148 128 1 19 164 1 162 73 1 188 193 1 61 68 1 128 74 1 52 160 1 41 94 1 71 144 1 30 143 1 9 191 1 156 40 1 91 182 1 112 35 1 10 112 1 11 65 1 25 87 1 134 156 1 161 159 1 38 183 1 145 81 1 105 153 1 70 90 1 190 7 1 145 69 1 188 53 1 109 195 1 47 ...
output:
2376
result:
ok single line: '2376'
Subtask #2:
score: 1
Accepted
Test #13:
score: 1
Accepted
time: 24ms
memory: 8520kb
input:
998 169780 35 591 212 658 312 892 457 419 922 946 525 390 314 997 415 984 631 167 168 59 59 901 922 958 234 592 639 76 456 482 340 214 705 34 170 224 681 763 291 383 811 705 131 280 647 912 652 723 579 715 576 651 5 296 233 522 835 467 976 853 713 521 316 454 506 470 709 618 522 41 338 359 242 107 4...
output:
743511194
result:
ok single line: '743511194'
Test #14:
score: 1
Accepted
time: 20ms
memory: 7384kb
input:
998 458956 201 18 467 410 545 572 736 754 109 144 572 310 18 317 329 128 586 852 230 579 498 471 640 123 78 265 973 362 343 490 657 351 423 841 428 480 532 219 596 933 248 552 385 34 882 548 406 628 82 427 419 596 181 557 650 150 456 343 233 14 989 114 746 409 968 180 879 935 556 485 719 576 581 854...
output:
644087633
result:
ok single line: '644087633'
Test #15:
score: 1
Accepted
time: 34ms
memory: 9444kb
input:
997 53385 106 540 369 911 779 170 496 176 587 250 94 61 16 675 704 543 552 10 727 451 501 532 567 355 575 869 991 594 607 738 414 548 315 374 781 592 411 878 552 899 922 753 101 992 824 121 937 237 923 725 883 794 832 303 72 6 770 505 929 790 278 868 59 599 268 23 9 608 966 807 687 962 527 526 971 1...
output:
107492756
result:
ok single line: '107492756'
Test #16:
score: 1
Accepted
time: 11ms
memory: 7340kb
input:
998 1 353 28 427 845 666 180 378 798 346 861 149 100 50 503 972 612 444 970 625 221 765 788 445 437 106 102 107 873 806 266 168 974 698 561 696 405 781 197 873 24 452 123 294 620 766 686 117 702 821 220 743 876 160 940 115 213 168 810 122 970 834 268 428 77 690 748 922 107 720 202 675 222 865 94 433...
output:
998
result:
ok single line: '998'
Test #17:
score: 1
Accepted
time: 35ms
memory: 9232kb
input:
998 434716 384 917 156 341 338 643 827 486 662 986 895 309 460 228 518 206 533 508 160 3 411 456 471 663 574 107 982 150 225 277 624 363 634 756 921 750 465 251 298 315 85 404 23 363 325 445 815 700 241 901 42 856 802 13 856 331 647 656 132 472 88 989 300 952 29 745 891 719 978 592 809 80 911 809 61...
output:
275220311
result:
ok single line: '275220311'
Test #18:
score: 1
Accepted
time: 33ms
memory: 9448kb
input:
997 209570 762 659 481 730 221 832 236 306 381 395 629 20 22 869 112 474 872 468 829 172 186 851 383 268 223 731 678 595 483 585 518 242 428 994 769 273 933 157 524 154 592 5 778 713 608 168 447 538 393 405 624 190 621 933 99 161 927 812 591 499 675 120 707 545 970 169 176 385 218 873 493 585 260 59...
output:
548635266
result:
ok single line: '548635266'
Test #19:
score: 1
Accepted
time: 32ms
memory: 7404kb
input:
998 284684 28 215 159 56 927 79 222 362 48 405 270 170 131 842 44 289 630 45 361 139 71 235 763 81 174 993 181 672 675 121 559 504 123 633 846 69 731 517 178 652 279 16 225 440 44 715 423 12 81 798 39 584 337 12 317 838 11 94 897 17 153 410 1 855 277 162 489 199 46 326 485 8 293 663 20 57 733 103 83...
output:
741488203
result:
ok single line: '741488203'
Test #20:
score: 1
Accepted
time: 27ms
memory: 5484kb
input:
998 104900 760 30 786 30 247 685 30 685 575 752 30 957 406 30 810 198 30 891 140 30 266 765 30 151 30 48 661 30 520 58 30 657 444 30 249 219 321 30 996 114 30 121 30 4 462 30 702 57 30 859 499 328 30 773 30 149 177 30 584 883 30 747 613 147 30 860 610 30 38 694 30 239 320 30 903 30 901 556 958 30 78...
output:
194451951
result:
ok single line: '194451951'
Test #21:
score: 1
Accepted
time: 26ms
memory: 7176kb
input:
962 173070 275 821 757 50 185 281 371 936 433 161 113 668 592 523 465 346 683 467 339 304 79 170 951 343 755 434 744 13 462 840 323 856 745 694 75 138 381 698 209 844 483 684 681 152 251 923 761 59 429 884 511 536 60 680 258 898 612 647 348 192 676 108 623 66 478 443 10 758 250 162 27 404 211 765 71...
output:
382463814
result:
ok single line: '382463814'
Test #22:
score: 1
Accepted
time: 34ms
memory: 8332kb
input:
1000 382483 873 546 782 918 202 700 932 402 323 107 555 618 74 844 595 38 816 230 223 473 690 695 702 735 441 44 319 529 289 981 716 500 231 276 705 472 355 669 123 578 41 655 842 362 970 372 652 86 155 393 441 126 7 123 494 562 234 648 967 504 348 520 70 977 202 575 23 69 403 293 943 651 593 98 76 ...
output:
651445973
result:
ok single line: '651445973'
Test #23:
score: 1
Accepted
time: 24ms
memory: 8620kb
input:
997 213740 18 412 128 828 504 829 975 609 597 322 783 909 215 795 679 106 534 635 742 707 954 755 952 605 978 837 111 79 859 497 913 536 342 69 72 575 388 422 35 243 805 260 537 596 661 967 498 5 967 391 8 570 875 508 101 537 659 546 181 984 722 147 672 781 370 200 129 84 42 863 951 168 927 181 986 ...
output:
437676757
result:
ok single line: '437676757'
Test #24:
score: 1
Accepted
time: 22ms
memory: 8104kb
input:
1000 441169 612 270 574 707 285 801 239 151 772 871 164 941 608 727 538 205 144 672 233 291 239 751 51 229 661 293 426 77 775 630 186 757 476 301 968 800 243 318 827 708 101 812 118 665 613 76 118 617 677 13 778 106 336 299 778 824 718 496 63 786 858 633 252 882 926 188 987 562 286 393 219 928 431 7...
output:
2667181
result:
ok single line: '2667181'
Test #25:
score: 1
Accepted
time: 29ms
memory: 6700kb
input:
999 449697 806 404 123 133 619 550 682 961 566 891 436 583 299 788 154 560 81 564 541 459 739 57 307 964 948 139 317 915 948 380 165 101 616 974 969 815 934 347 486 346 774 716 375 928 487 375 186 980 613 948 849 679 690 723 228 999 579 811 337 915 884 365 113 501 948 347 948 214 652 57 668 739 689 ...
output:
272689609
result:
ok single line: '272689609'
Test #26:
score: 1
Accepted
time: 3ms
memory: 6660kb
input:
997 218029 215 132 1 229 777 1 115 104 1 340 640 1 280 873 1 726 380 1 280 20 1 313 156 1 522 113 1 579 687 1 69 465 1 350 376 1 564 685 1 270 881 1 931 872 1 921 435 1 361 237 1 831 456 1 484 399 1 830 95 1 405 894 1 397 607 1 162 821 1 292 809 1 145 115 1 645 270 1 975 835 1 425 107 1 186 498 1 97...
output:
10967
result:
ok single line: '10967'
Subtask #3:
score: 1
Accepted
Test #27:
score: 1
Accepted
time: 113ms
memory: 13148kb
input:
2500 2247412 1611 1854 1456 1902 1948 343 1578 1483 2302 1950 746 1812 278 1882 1349 1462 1505 1496 1471 1079 1238 1495 311 1023 746 1247 433 229 1707 489 1562 1582 359 470 1221 1403 227 821 904 1848 1026 2342 2119 2396 1563 1611 1312 1830 1706 791 936 1964 1868 786 250 1973 1374 1364 2311 327 1828 ...
output:
708105529
result:
ok single line: '708105529'
Test #28:
score: 1
Accepted
time: 147ms
memory: 13700kb
input:
2500 2065641 1186 2086 934 897 1437 1771 1578 895 1869 1389 1457 282 1526 2463 1309 825 2152 1103 2365 1538 509 1380 1314 2413 2115 556 673 3 1375 383 370 1663 2127 1151 2289 1015 285 118 2385 891 1182 1774 1029 1921 421 1545 1811 93 1038 1576 503 1339 862 27 2490 176 2155 1606 613 366 876 1675 1622...
output:
198355846
result:
ok single line: '198355846'
Test #29:
score: 1
Accepted
time: 183ms
memory: 15856kb
input:
2499 492349 126 860 2233 1837 1546 2200 1388 82 1740 794 2405 486 825 684 1019 268 2189 1115 1422 835 1559 977 660 1814 1699 1594 2238 698 2361 1185 1443 1389 1048 1396 2251 328 1797 2479 340 309 2454 962 1631 1047 1358 438 1049 540 2458 793 1996 608 602 184 1051 1493 1870 2286 646 1838 22 1440 2210...
output:
806016141
result:
ok single line: '806016141'
Test #30:
score: 1
Accepted
time: 46ms
memory: 11668kb
input:
2498 3118753 2207 2323 1942 229 1946 2404 494 269 504 1048 870 1132 617 1101 1785 1333 6 761 1938 1721 307 971 1240 1216 1437 381 987 1836 1812 1898 682 1902 2302 2055 141 645 1794 2440 1229 1276 1379 1587 104 2425 629 407 2220 300 1693 868 1431 400 1771 1460 700 1157 527 2088 249 32 2168 1650 1673 ...
output:
946898534
result:
ok single line: '946898534'
Test #31:
score: 1
Accepted
time: 151ms
memory: 17084kb
input:
2500 1055207 1884 876 1028 2141 1330 244 2345 143 1830 1150 1873 493 1492 1461 1404 404 1007 642 2493 323 1612 1650 817 2251 1277 2106 1114 1944 2447 597 1340 2039 1906 486 1031 1386 2147 31 133 1058 1544 331 1758 806 1368 2282 1127 1607 2343 921 914 114 1231 149 26 446 1525 252 2160 439 650 1700 60...
output:
539427514
result:
ok single line: '539427514'
Test #32:
score: 1
Accepted
time: 77ms
memory: 13936kb
input:
2498 1532441 1738 986 2316 2016 213 658 1744 1648 2140 1900 2087 240 1094 396 2259 853 1210 1975 1834 357 68 1233 1595 1063 1077 1242 1107 508 627 1101 1812 1132 1343 1409 374 960 1710 747 394 320 2325 1035 2437 324 1864 383 694 2457 506 840 2312 1937 316 262 2201 994 1839 965 80 307 443 2170 552 22...
output:
985142299
result:
ok single line: '985142299'
Test #33:
score: 1
Accepted
time: 94ms
memory: 15572kb
input:
2498 266144 2357 1383 444 165 154 125 1611 2410 623 1689 1274 208 877 47 142 271 2349 317 2356 1639 71 2224 1064 245 1840 1540 360 389 265 471 850 2024 3 1754 1193 106 248 362 332 2173 2057 643 339 852 777 990 22 436 1070 689 456 214 1962 781 1070 2401 457 527 699 652 293 909 306 577 2240 554 1545 7...
output:
523180032
result:
ok single line: '523180032'
Test #34:
score: 1
Accepted
time: 153ms
memory: 16788kb
input:
2499 2667800 328 2013 2443 1385 257 1765 1032 410 1456 1896 2 1698 1082 530 2289 244 742 2128 29 299 1377 2086 2197 1278 252 1599 1209 1703 2187 242 2423 1938 1893 1081 2420 381 113 432 131 44 1136 2031 1075 1208 1419 851 1983 1468 247 2036 1345 902 98 2198 1598 1667 310 1199 1261 492 1427 1751 1476...
output:
723571209
result:
ok single line: '723571209'
Test #35:
score: 1
Accepted
time: 116ms
memory: 10836kb
input:
2499 17789 264 2240 1479 1832 264 1156 964 264 1502 2162 264 1421 264 160 1878 264 1677 1975 264 2463 1899 264 2112 68 189 264 1432 264 2320 1347 214 264 439 623 264 787 2386 264 2303 264 1396 2004 1938 264 1229 1162 264 2165 264 1450 1840 264 1304 125 1179 264 1434 1977 264 649 2194 264 699 1321 26...
output:
143116053
result:
ok single line: '143116053'
Test #36:
score: 1
Accepted
time: 141ms
memory: 17948kb
input:
2402 887963 2003 2164 963 545 645 170 754 2358 1900 310 1597 1553 2255 1030 37 796 486 1628 580 396 641 2397 850 1080 879 925 22 1841 64 558 1260 1622 284 55 922 1398 649 2367 1800 703 268 1878 1436 838 2058 1997 2050 438 1456 2234 84 941 1347 1126 431 399 191 210 318 1869 2188 393 2293 707 1606 691...
output:
14110773
result:
ok single line: '14110773'
Test #37:
score: 1
Accepted
time: 153ms
memory: 12684kb
input:
2497 2118905 1231 580 1599 2462 924 2231 474 1945 288 1936 1542 30 1992 2392 25 1546 2272 2280 605 2407 2067 871 2311 2429 1052 2392 132 662 419 540 1605 1734 842 343 1807 2087 237 1669 331 2104 1918 221 686 551 2162 1395 1832 1704 1604 1446 1049 384 2404 2175 2218 1832 488 960 1779 358 1246 1733 16...
output:
394956518
result:
ok single line: '394956518'
Test #38:
score: 1
Accepted
time: 103ms
memory: 14796kb
input:
2499 2374589 133 916 325 1811 2050 1816 2258 1415 338 405 1592 200 2376 1519 169 38 621 1231 608 113 2052 1360 1657 1152 660 904 1791 110 328 1641 156 809 1963 2203 2280 2355 1082 1841 244 185 1297 264 1850 1220 178 1572 1087 964 2493 1633 769 923 141 1238 1685 912 958 844 1174 1404 1685 366 957 219...
output:
906826478
result:
ok single line: '906826478'
Test #39:
score: 1
Accepted
time: 138ms
memory: 15536kb
input:
2498 903160 197 1859 1302 2192 235 1216 2280 1277 1027 2273 1605 1666 112 1787 2175 160 1377 2229 31 2231 1047 1193 570 518 2333 1713 266 1094 1983 2122 1510 1872 1205 1705 1549 357 2104 1923 2271 1141 1173 1468 1790 1189 2030 1726 2063 517 2244 366 2188 2050 684 1413 2008 1468 654 2055 831 241 401 ...
output:
716653537
result:
ok single line: '716653537'
Test #40:
score: 1
Accepted
time: 19ms
memory: 9884kb
input:
2497 682422 934 2470 1 1352 2277 1 474 815 1 1894 2237 1 1526 1677 1 2232 1142 1 2177 590 1 1002 974 1 666 764 1 1904 378 1 1701 1732 1 1431 1132 1 53 913 1 1096 1888 1 1885 29 1 466 332 1 836 1483 1 1818 647 1 954 1891 1 2076 611 1 788 2041 1 1174 1209 1 1902 561 1 1758 1864 1 611 92 1 2394 1446 1 ...
output:
24970
result:
ok single line: '24970'
Subtask #4:
score: 1
Accepted
Test #41:
score: 1
Accepted
time: 776ms
memory: 46068kb
input:
9999 15821648 8636 2283 3583 3676 1194 3330 549 1670 9159 1859 9943 8343 2262 3482 2821 7565 5757 231 4104 7610 9713 9054 4110 9631 894 9288 1864 7256 9972 9596 8007 509 9472 2213 1290 3679 9810 8406 8130 2389 2659 7960 9765 7697 6384 2873 8937 5494 381 8657 2784 1155 2467 3703 4529 9371 265 3303 69...
output:
712073339
result:
ok single line: '712073339'
Test #42:
score: 1
Accepted
time: 830ms
memory: 45688kb
input:
9998 19543554 7207 7270 3497 8245 2944 8723 2003 4235 4724 2751 6428 1127 5865 4710 6887 7717 4397 2380 9670 1378 4416 5324 2930 9233 3209 8604 200 216 8503 605 9139 6475 1204 2814 7193 1342 1490 6599 4471 9424 7691 4409 220 714 2122 8212 5514 6534 2138 3851 6458 2523 8401 488 5726 62 1897 3127 6251...
output:
343758348
result:
ok single line: '343758348'
Test #43:
score: 1
Accepted
time: 666ms
memory: 62412kb
input:
9997 49802412 4277 7769 3220 5030 3534 9017 3474 7045 6844 9004 8724 1900 3840 9110 2512 2055 3490 9748 7796 2252 9321 5958 3081 6816 8813 7525 3713 2610 597 1624 3093 8432 8616 707 642 8790 5293 8727 6274 8705 3341 4077 1096 5217 4137 641 6001 6479 2011 9174 4476 9739 5948 6013 1405 1298 3146 2425 ...
output:
380761638
result:
ok single line: '380761638'
Test #44:
score: 1
Accepted
time: 368ms
memory: 36544kb
input:
9997 1 1328 8368 5099 7641 7328 8071 1542 6204 7927 7847 1226 4249 1 2872 1294 3458 9974 2131 9829 7995 8635 3963 1588 4423 4647 9672 6975 5063 6328 2635 303 3430 6559 3141 8482 6973 2241 4772 7327 5136 5951 2412 7423 9686 8728 2359 540 4939 5370 6773 4668 4030 9827 8826 6523 9078 644 9612 2053 1916...
output:
99940009
result:
ok single line: '99940009'
Test #45:
score: 1
Accepted
time: 341ms
memory: 38616kb
input:
9997 49965006 4779 8380 6968 5576 4250 1433 4613 8672 8118 152 6991 7147 4599 9266 4426 6528 3547 2659 2658 1579 2568 4907 9354 4716 3521 4530 4704 4788 1039 9274 5244 321 6642 7698 9129 6148 1455 8581 1513 8159 235 4525 1395 5275 6700 2650 828 3992 2086 6852 4212 4701 2829 1499 7960 2225 9691 2105 ...
output:
756621753
result:
ok single line: '756621753'
Test #46:
score: 1
Accepted
time: 874ms
memory: 60636kb
input:
9998 11853511 489 901 8056 6835 6058 1490 9159 9563 9881 2196 6977 5128 3185 4871 7344 1263 6290 2079 6619 9181 6512 6426 1234 5356 9200 5536 1621 9164 250 1025 6515 9365 4310 247 635 4760 5165 1291 937 4615 9508 8296 3386 4824 3093 8936 7795 3443 1189 1025 5831 8243 8292 5329 5720 5188 6091 9847 42...
output:
989299261
result:
ok single line: '989299261'
Test #47:
score: 1
Accepted
time: 909ms
memory: 52328kb
input:
9998 36672210 9063 3884 7517 5754 4283 5563 5661 5562 1523 6334 2204 6718 9390 7445 7969 7507 2788 530 154 5336 3420 2561 4644 7219 32 5990 4155 5307 8687 9853 6675 4217 5640 9873 9816 9015 5462 3146 501 1239 5793 1916 2476 3768 273 2960 8470 1642 8269 8896 228 1566 5883 1552 933 2224 1210 5133 6943...
output:
668499904
result:
ok single line: '668499904'
Test #48:
score: 1
Accepted
time: 816ms
memory: 54748kb
input:
9998 46484612 9590 6356 422 6337 4702 927 3852 7839 192 5048 9581 804 1229 7919 185 5234 7371 60 3266 9857 875 206 2470 426 513 5429 487 5756 7764 473 9592 1089 572 8138 1368 96 3669 1841 516 3114 1069 350 1877 8562 356 9542 6937 738 6096 2243 732 6759 9054 36 4007 4843 87 1310 1139 236 8962 7358 25...
output:
986528956
result:
ok single line: '986528956'
Test #49:
score: 1
Accepted
time: 1276ms
memory: 60020kb
input:
9998 28159810 2107 7595 254 4048 2364 9237 1430 6791 6581 5431 265 9941 7756 982 6162 1806 429 5206 838 2315 1701 3931 3170 7344 8815 4627 6633 9095 9756 2200 5 6552 7301 5206 4241 7028 9503 418 6921 2525 4078 1567 5149 9108 9996 6615 8520 4134 1714 5250 2329 8393 2951 2588 8305 205 9978 6995 9101 4...
output:
889459272
result:
ok single line: '889459272'
Test #50:
score: 1
Accepted
time: 1007ms
memory: 28252kb
input:
9998 42944217 7653 908 8645 908 7882 6576 3778 908 7684 637 908 7696 908 8447 9800 7216 908 6232 908 8407 7038 908 2179 8663 908 3633 8528 908 3396 8301 908 6118 9392 1932 908 7824 908 5194 2784 908 6699 2805 7415 908 8561 908 6323 9827 6708 908 5283 6787 908 5168 908 3585 3183 1146 908 35 908 1675 ...
output:
317291862
result:
ok single line: '317291862'
Test #51:
score: 1
Accepted
time: 1136ms
memory: 69548kb
input:
9802 38183037 5237 3608 7802 7823 4453 3561 2552 5220 8202 9286 5033 2641 6543 8556 762 8931 9281 6710 1592 7505 8921 9685 1905 8892 3726 5402 4070 5736 2930 6242 118 9075 1941 7696 5285 1675 4231 9737 1233 8952 6546 5143 975 1835 1782 5537 8002 4236 5397 9367 3639 6742 3135 3656 3672 1464 3498 3108...
output:
306650970
result:
ok single line: '306650970'
Test #52:
score: 1
Accepted
time: 1120ms
memory: 46480kb
input:
10000 20097599 4042 3123 8917 7911 9153 1354 4139 6929 2936 1993 4555 7774 1823 9596 2349 6261 9573 6788 3970 9926 1743 2909 1531 5742 6219 4830 1497 6310 3244 7651 4588 6854 2970 4972 4494 9040 7102 2449 7709 5107 1655 1616 903 396 765 2188 9623 3122 7477 7285 7219 283 2166 639 9314 7861 2475 1738 ...
output:
354919492
result:
ok single line: '354919492'
Test #53:
score: 1
Accepted
time: 907ms
memory: 59428kb
input:
9998 14774078 7635 6966 850 3127 5854 524 9377 3316 8745 6735 4594 8131 103 825 7125 9803 3252 6977 1500 2972 9816 549 9866 885 6353 3715 7256 7325 8144 2296 534 354 1109 1300 995 8123 6563 4923 32 665 3098 763 7011 7297 6377 7058 6103 9686 1591 6732 8525 8870 888 8266 267 435 5306 5245 2657 1536 29...
output:
630183021
result:
ok single line: '630183021'
Test #54:
score: 1
Accepted
time: 715ms
memory: 48744kb
input:
9999 26418107 3733 7915 1314 211 8287 1199 484 6147 5047 9778 272 2219 5395 4357 1034 7171 1411 1042 4573 8684 8102 6114 196 5217 2504 9772 9431 2556 923 90 3543 7469 1877 102 1700 668 408 2135 9405 8992 1401 5013 9006 8737 7824 3415 8574 2459 441 6117 230 6288 9632 7823 5926 6990 2097 1668 8543 326...
output:
337322642
result:
ok single line: '337322642'
Test #55:
score: 1
Accepted
time: 877ms
memory: 39464kb
input:
9999 22690027 7828 9564 611 4247 530 7682 3364 6609 536 6533 5831 591 6392 1681 6483 6989 799 3240 2185 5118 3611 963 8720 6250 6200 1486 1289 6989 6454 8835 5438 1651 421 8808 6809 2983 3191 3855 9755 9349 5229 7799 7670 7751 7362 2828 4685 7507 9564 8963 7070 3795 4126 2902 5733 9682 1657 8232 165...
output:
889444998
result:
ok single line: '889444998'
Test #56:
score: 1
Accepted
time: 228ms
memory: 36440kb
input:
10000 39443942 188 5223 1 4352 2530 1 5379 6974 1 5626 4152 1 6993 7509 1 4255 2275 1 2225 3828 1 3311 9623 1 7526 388 1 7276 5194 1 2103 1084 1 6222 3212 1 5967 517 1 4567 8059 1 3489 5952 1 8235 8688 1 651 8914 1 2401 755 1 8850 2629 1 1091 9415 1 164 2117 1 6952 8688 1 7067 7132 1 4969 740 1 7632...
output:
190000
result:
ok single line: '190000'
Subtask #5:
score: 1
Accepted
Test #57:
score: 1
Accepted
time: 49ms
memory: 10696kb
input:
2000 1136449 1897 741 1 1322 1497 2 982 1323 2 1966 1365 4 1470 1717 1 1720 515 1 1782 1752 2 250 800 2 1972 1570 1 181 783 1 1865 448 1 700 515 1 1293 484 4 1224 1476 1 1411 1328 1 836 1553 4 674 1412 1 714 1336 3 1407 1181 3 431 1357 3 1735 764 1 76 222 3 1633 800 4 343 790 4 1140 1745 3 949 946 2...
output:
3557832
result:
ok single line: '3557832'
Test #58:
score: 1
Accepted
time: 79ms
memory: 12972kb
input:
2000 911546 940 975 4 1877 1115 4 1181 436 3 524 1998 3 602 1550 3 887 1006 3 336 56 1 1504 877 3 1547 598 1 1725 593 1 1346 399 4 1911 545 3 1081 1823 2 1923 70 4 329 812 2 734 377 1 790 935 2 741 638 1 807 238 2 865 1954 4 1267 1928 3 1317 35 1 811 1324 3 98 1986 4 1949 922 4 254 87 4 355 612 3 53...
output:
584474552
result:
ok single line: '584474552'
Test #59:
score: 1
Accepted
time: 39ms
memory: 9476kb
input:
2000 1 1656 1385 4 624 880 3 595 564 1 231 1727 1 590 1907 3 314 1535 4 1565 210 4 846 381 4 274 877 4 1999 1704 4 82 436 1 1961 344 2 772 1769 4 510 1641 4 1907 1172 2 1160 1198 2 947 622 1 835 6 3 1261 761 1 1060 1253 1 991 1464 1 477 348 4 1389 650 3 1424 664 1 1458 194 4 420 996 2 474 615 2 1318...
output:
2000
result:
ok single line: '2000'
Test #60:
score: 1
Accepted
time: 43ms
memory: 10764kb
input:
2000 1999000 1439 1652 2 503 1199 4 1297 935 2 910 1864 2 1668 1678 3 1940 246 1 1236 1218 3 122 825 2 1419 495 4 1540 510 4 350 1039 4 1820 834 1 249 818 1 1767 616 2 1823 1642 3 958 1358 4 1409 27 2 1652 1443 3 1909 1305 3 633 382 1 68 1724 4 1059 293 2 544 1920 3 1397 395 3 1764 938 4 1030 1773 2...
output:
10435832
result:
ok single line: '10435832'
Test #61:
score: 1
Accepted
time: 74ms
memory: 13372kb
input:
1999 767964 1739 137 2 223 1296 3 1605 1320 1 312 790 1 1943 927 2 1175 508 4 95 1122 3 1723 814 2 1735 306 3 563 1635 2 103 1036 1 1400 348 1 711 1990 3 220 326 1 937 1035 3 1678 860 2 1155 230 4 1299 966 2 750 1971 1 12 296 1 1051 480 4 1200 113 1 879 1392 3 72 1982 4 1965 1786 4 463 1783 2 368 70...
output:
853998946
result:
ok single line: '853998946'
Test #62:
score: 1
Accepted
time: 45ms
memory: 11712kb
input:
1999 544832 110 917 4 116 993 3 86 1947 1 8 1846 3 1202 163 3 127 1326 3 658 437 1 22 1364 2 959 409 4 1238 23 3 1621 630 1 1089 492 4 1385 1250 2 1040 544 1 1170 382 1 812 372 2 237 937 1 1427 1348 1 1106 1009 3 532 1041 1 1533 703 4 1781 2 1 293 116 3 1354 498 3 787 1599 3 1256 733 4 1399 876 2 18...
output:
150639954
result:
ok single line: '150639954'
Test #63:
score: 1
Accepted
time: 9ms
memory: 6796kb
input:
2000 341296 345 1497 2 345 1297 3 345 1951 2 345 511 1 345 935 2 345 504 2 149 345 3 1169 345 2 1173 345 2 1579 345 2 669 345 3 1691 345 1 345 420 2 345 921 2 973 345 2 1774 345 2 345 227 4 345 1724 3 480 345 2 181 345 4 345 1622 1 345 1096 3 881 345 2 345 1674 3 345 1808 4 580 345 1 345 1360 1 345 ...
output:
4002000
result:
ok single line: '4002000'
Test #64:
score: 1
Accepted
time: 31ms
memory: 8768kb
input:
1998 1232111 1694 1993 3 149 128 1 1715 447 3 177 1406 3 1406 376 2 1449 609 4 1492 1508 4 1573 432 1 41 1406 2 1492 1556 1 194 1406 2 929 1897 2 1829 1596 3 1795 1610 3 1791 605 1 348 265 4 1406 1592 1 1531 1111 1 1492 845 2 1847 605 1 1694 1829 2 1109 320 4 300 1566 2 1694 1626 3 1764 1406 3 1213 ...
output:
83826410
result:
ok single line: '83826410'
Subtask #6:
score: 1
Accepted
Test #65:
score: 1
Accepted
time: 1340ms
memory: 101856kb
input:
25000 129936618 23905 3220 2 8628 7162 4 7712 7174 4 5303 10130 4 8637 15576 1 15540 14742 1 4893 17862 1 23447 6412 4 24739 9418 2 15421 16023 2 23553 18251 3 10780 10757 4 3944 14506 4 508 4268 1 17208 21779 2 11823 1053 2 16019 11570 3 8495 23725 1 9017 6758 2 4574 8148 4 7613 13409 3 16793 6701 ...
output:
312162570
result:
ok single line: '312162570'
Test #66:
score: 1
Accepted
time: 2447ms
memory: 172300kb
input:
24999 7374334 6636 9146 2 16406 7492 2 1015 11328 4 13089 8771 4 17017 24046 1 11403 2520 4 15716 6352 4 3710 10958 3 23291 23337 2 4247 8779 2 14546 6109 1 362 8087 3 19171 20724 3 9341 24433 4 3889 3174 4 2217 1431 3 13012 11973 4 24579 4995 2 6146 4128 3 16732 6326 3 5328 16906 2 5485 18811 3 108...
output:
300712652
result:
ok single line: '300712652'
Test #67:
score: 1
Accepted
time: 772ms
memory: 95872kb
input:
24999 1 6389 22108 3 805 16788 2 1446 20151 4 5976 3717 1 19956 13892 2 13051 6847 1 9705 3071 4 13393 17245 1 23723 7745 4 14488 363 2 3828 13717 4 22607 12058 2 9366 2101 3 15998 22159 1 22664 14785 2 4153 2299 4 24402 6645 1 6047 20933 1 16697 3192 1 13780 16189 1 17643 13696 1 16804 19375 3 1072...
output:
24999
result:
ok single line: '24999'
Test #68:
score: 1
Accepted
time: 2202ms
memory: 158752kb
input:
25000 202207613 22773 15336 1 14929 4631 3 15692 23480 1 14049 23756 2 19472 10178 2 12157 2665 3 18977 9663 2 23171 21895 3 12031 11204 3 11019 16904 2 20669 14320 2 13647 12076 2 17383 15503 2 3757 9936 3 16450 18252 2 21297 24064 3 13382 10385 4 6961 3843 4 14558 24518 4 19234 12016 3 7724 13703 ...
output:
143590138
result:
ok single line: '143590138'
Test #69:
score: 1
Accepted
time: 2564ms
memory: 152176kb
input:
24999 109751912 24829 724 4 10918 213 2 19349 9282 3 8721 6045 3 15640 8354 2 17697 13132 4 24433 4631 4 18398 9200 3 2570 21376 3 18670 6744 3 5061 3601 1 22376 4324 2 10190 19152 1 6833 7318 2 11508 336 2 12879 10711 3 6827 18606 4 6257 24403 4 23127 14280 2 945 13659 4 781 17160 1 3138 11824 3 19...
output:
260262901
result:
ok single line: '260262901'
Test #70:
score: 1
Accepted
time: 2675ms
memory: 139672kb
input:
24998 48524326 16023 5913 1 12150 12204 4 14364 21235 3 22886 2023 2 11168 474 2 11071 6490 2 11063 21239 1 15387 14252 4 11420 9316 3 21545 3597 1 12341 19628 4 16094 1434 3 17877 16532 2 22735 14226 1 8349 4378 2 10862 17338 2 23823 2297 4 19705 191 4 19504 15373 1 8840 11591 4 10734 15647 2 9405 ...
output:
926330365
result:
ok single line: '926330365'
Test #71:
score: 1
Accepted
time: 304ms
memory: 31848kb
input:
25000 202222151 9536 2577 4 2577 21608 1 2577 1089 3 2577 5188 1 15109 2577 2 2577 19138 3 11773 2577 2 18183 2577 1 3551 2577 4 9238 2577 1 2577 24263 1 22784 2577 2 2577 299 2 4751 2577 2 2577 24158 3 10019 2577 2 21784 2577 1 4529 2577 3 18940 2577 4 14439 2577 3 23927 2577 4 12186 2577 4 2577 14...
output:
265650021
result:
ok single line: '265650021'
Test #72:
score: 1
Accepted
time: 3053ms
memory: 177580kb
input:
24965 141029234 6748 6645 1 1194 9094 3 12377 18851 4 5857 8280 1 21942 148 1 23932 10797 3 3422 3182 2 9914 21154 3 21819 7757 3 13448 10408 1 21114 7489 1 18844 19050 3 23013 20369 4 11679 15746 2 18857 14173 3 2187 23547 4 4757 15727 3 13761 3923 1 17805 18473 4 18880 6225 2 1386 22583 3 595 6278...
output:
191189377
result:
ok single line: '191189377'
Test #73:
score: 1
Accepted
time: 450ms
memory: 48496kb
input:
24997 100488302 14589 8794 2 19035 9654 3 7622 21569 1 15965 12750 1 13942 15949 2 18464 3337 4 2 18173 4 11109 15530 3 291 15257 4 2200 2869 4 3577 19408 1 7064 14317 3 20339 14114 4 10778 24807 4 23618 12504 1 21026 5128 3 19524 21398 1 8096 19035 1 1027 21718 3 22984 18388 3 8309 2688 4 6016 2301...
output:
389852998
result:
ok single line: '389852998'
Subtask #7:
score: 1
Accepted
Test #74:
score: 1
Accepted
time: 2859ms
memory: 120948kb
input:
24998 270959647 8335 8667 22931 6263 17208 11850 15627 20983 12016 9124 12152 537 10682 23970 15466 17490 1331 23154 11060 17832 9657 13055 2472 12469 16839 20693 20857 24502 21974 20091 18354 20435 18289 1910 11929 24448 10176 4942 22869 14808 4055 13274 5151 5070 3347 10289 22966 20390 16112 17593...
output:
173906489
result:
ok single line: '173906489'
Test #75:
score: 1
Accepted
time: 2596ms
memory: 161004kb
input:
24999 281428066 1842 506 3397 24639 24181 12213 18850 602 4996 24979 11249 20302 22864 16612 4771 22359 5190 19505 18384 22599 24498 9642 22951 23783 23862 10088 22112 1583 7790 18028 8164 23385 2281 5870 21756 3400 12917 3839 9236 8497 239 15830 21523 1697 24681 9902 9836 17433 15739 5821 15840 302...
output:
209949017
result:
ok single line: '209949017'
Test #76:
score: 1
Accepted
time: 2850ms
memory: 177356kb
input:
24965 293134434 310 14745 2884 5221 13012 2000 428 14208 21933 9385 1876 9346 13420 18170 19593 6166 1628 18910 9363 7089 17603 13438 9371 12974 12047 21043 22065 22480 4986 6194 5708 4790 15973 6750 11898 5135 19205 12952 16475 8306 16994 17612 17636 20281 21168 5272 21099 475 12585 273 22045 12508...
output:
197822890
result:
ok single line: '197822890'
Test #77:
score: 1
Accepted
time: 3313ms
memory: 131916kb
input:
24998 105917472 16807 13313 22293 8389 9466 16727 17700 10484 11511 4929 12216 10624 18300 757 17071 23624 12212 23978 6984 2613 20979 14138 24100 10612 19119 6288 17744 7298 5015 4049 19548 11492 24756 16493 13530 7930 17589 14648 11022 17924 5727 9490 23385 22634 11941 9686 6473 17801 21197 24307 ...
output:
387065021
result:
ok single line: '387065021'
Test #78:
score: 1
Accepted
time: 1712ms
memory: 106476kb
input:
24997 312412506 2451 6410 10028 12446 10877 4919 21451 5321 3351 1839 15742 9432 21691 7267 954 18292 346 12101 4784 18755 7201 20320 13801 11273 17991 10900 16040 8617 11716 13269 2091 23041 10267 6387 8059 20408 11194 5495 13568 23093 22119 7727 6415 10037 14693 2047 21440 18500 13029 17327 23264 ...
output:
225881083
result:
ok single line: '225881083'
Test #79:
score: 1
Accepted
time: 1955ms
memory: 155440kb
input:
24997 2929563 11285 19693 2 1753 19339 2 21265 23265 2 23491 6937 2 16678 12379 1 20963 22078 2 12396 2054 1 1665 10465 1 6509 15353 1 20579 22763 2 16367 21493 2 9853 21673 2 14731 23482 2 8874 3762 1 21398 22245 1 4655 5853 2 18009 503 1 6495 19210 2 6505 8648 2 18356 2330 1 6706 7628 2 20582 1473...
output:
997424995
result:
ok single line: '997424995'
Subtask #8:
score: 1
Accepted
Test #80:
score: 1
Accepted
time: 2903ms
memory: 175912kb
input:
24999 162697837 3863 8678 15285 12285 5328 8052 2956 7987 21748 19895 20559 13616 611 23357 7976 16032 159 9574 12784 5957 10441 18346 18634 15298 20339 1728 7364 20967 1003 8885 12018 5015 6059 24328 11132 7113 4133 14827 3214 1066 335 5214 106 22621 337 13652 23902 24845 13500 11861 6392 14914 213...
output:
334159708
result:
ok single line: '334159708'
Test #81:
score: 1
Accepted
time: 2910ms
memory: 152112kb
input:
24998 14212005 22935 22749 14197 13611 12311 5962 12445 9504 23145 7411 2744 21043 15441 1945 18119 9257 3843 16513 2663 17688 15128 1175 5327 5721 8325 2304 3787 12760 2950 18905 6418 7604 2320 11695 7118 14180 13938 23519 6570 2687 24500 15122 24554 16871 11535 17164 2906 5125 1782 7533 13577 1267...
output:
971995659
result:
ok single line: '971995659'
Test #82:
score: 1
Accepted
time: 4202ms
memory: 129820kb
input:
24999 103807866 3206 22864 18052 430 7633 7774 16442 11267 5547 9194 2235 22722 2962 13440 21772 6475 2808 7675 7252 14220 24306 9612 7700 7700 9588 5028 24188 23362 1738 17395 590 24893 23493 8229 21484 9346 24938 8159 11417 13201 12122 249 12122 4355 93 19893 20234 7520 938 18453 11874 21975 6385 ...
output:
107969556
result:
ok single line: '107969556'
Test #83:
score: 1
Accepted
time: 2525ms
memory: 74852kb
input:
24998 116099791 23793 13642 11435 109 6798 15630 7521 100 17451 7288 211 19701 6119 20238 23423 12038 6798 5991 327 7835 5038 11869 100 22814 18068 24893 8203 6798 12847 10169 312 100 17444 21182 22264 22124 10152 4666 12538 7205 16919 9638 24407 1828 4141 2037 390 3198 23478 10864 3894 17671 596 19...
output:
620628511
result:
ok single line: '620628511'
Test #84:
score: 1
Accepted
time: 2882ms
memory: 125356kb
input:
25000 72493860 7421 11429 5 8997 11516 8 5012 16208 6 5410 23024 9 3286 4193 10 13576 4799 7 1245 1257 7 19294 1967 12 10664 17700 1 17821 24667 11 147 13837 9 18334 19965 4 13250 5838 9 9818 7435 4 18835 1562 5 941 19359 12 10253 7126 3 19286 22019 6 13324 1564 6 4266 13196 3 24348 7199 10 6065 222...
output:
103095322
result:
ok single line: '103095322'
Test #85:
score: 1
Accepted
time: 4065ms
memory: 178860kb
input:
24998 155788552 4206 10161 3 4557 7796 7 4455 17397 4 18779 12891 3 7615 8517 4 23023 14865 4 2673 4797 7 23072 23062 7 4437 15562 3 3498 18132 6 17099 12280 6 952 7326 3 11196 13210 6 18546 19805 4 19238 14933 1 5203 24578 5 11528 11084 4 1284 19317 7 10117 23866 3 12118 8798 6 23347 23925 7 15920 ...
output:
819163798
result:
ok single line: '819163798'
Subtask #9:
score: 1
Accepted
Test #86:
score: 1
Accepted
time: 1438ms
memory: 104328kb
input:
25000 312487500 14733 13471 22965 6623 11948 1721 10154 6394 1605 16485 18707 16949 19858 12088 9649 14536 999 20975 5292 18753 18098 7221 253 11356 22379 7158 22414 19105 21527 7748 15783 20782 14153 6102 14707 5455 14923 23093 6953 11692 13204 3669 5691 125 18579 18454 15981 4616 1315 23705 14413 ...
output:
420913732
result:
ok single line: '420913732'
Test #87:
score: 1
Accepted
time: 2623ms
memory: 138244kb
input:
24998 227709291 16046 9028 15085 18268 15141 2880 17212 3825 22531 6932 13755 2300 19951 19055 20115 1098 9284 468 16539 20248 17205 17685 10591 14809 19582 24926 912 17423 23145 16919 4253 23932 10592 7600 22451 15823 4661 12312 14288 19312 16539 8964 8210 5796 652 18592 6672 10864 16607 9562 24658...
output:
898200675
result:
ok single line: '898200675'
Test #88:
score: 1
Accepted
time: 2797ms
memory: 172952kb
input:
24998 83770697 23308 2048 11646 15516 5524 5676 17401 3347 20053 4581 13071 14994 17041 8877 1603 7314 20593 13340 15597 9355 1368 10000 19639 18058 3168 10554 15333 18830 22561 23599 15612 22046 4772 3885 385 23452 4793 6910 2935 18419 5986 1485 15224 19720 7485 4020 19235 18941 12589 1680 1471 174...
output:
294937152
result:
ok single line: '294937152'
Test #89:
score: 1
Accepted
time: 2328ms
memory: 72940kb
input:
24998 216260058 20837 20452 42 13137 10458 34 5895 2249 25 2563 15016 44 5895 16750 46 7576 13682 33 3557 17906 30 17297 13723 8 13723 9014 45 10914 16173 22 7072 7968 22 13511 17402 46 10760 24587 37 13348 13885 19 22762 7280 37 16438 13723 12 8699 21782 39 842 5318 3 7280 771 25 23030 5895 47 6620...
output:
856896556
result:
ok single line: '856896556'
Test #90:
score: 1
Accepted
time: 3259ms
memory: 164728kb
input:
25000 219868008 12984 12951 4890 17770 18370 1344 15106 13234 4680 7544 22314 1433 14975 7273 3172 14616 17358 1897 1583 18818 470 15751 24112 3012 16988 19964 1017 17232 23501 2434 1411 2125 3032 13740 19009 3179 6879 18896 1897 4248 8252 1644 17143 13731 2690 17220 16429 2206 2287 13482 3593 17477...
output:
396567505
result:
ok single line: '396567505'
Subtask #10:
score: 1
Accepted
Test #91:
score: 1
Accepted
time: 3534ms
memory: 178464kb
input:
25000 144174368 12978 4004 1982 16415 16135 1480 16553 3304 22094 14424 180 1117 18758 6172 24402 23235 3765 5892 945 18802 18519 6131 10599 7134 16162 1731 14738 2533 7011 9995 16771 3637 23426 24503 3772 13345 13725 18786 13061 17982 9364 5624 18866 5823 385 10033 1632 17037 22494 22061 4308 18748...
output:
11538981
result:
ok single line: '11538981'
Test #92:
score: 1
Accepted
time: 4452ms
memory: 71264kb
input:
24999 177991814 16065 11157 16130 3154 16065 12428 24271 16065 21519 1469 16065 24363 16065 24446 2953 14780 16065 23384 16065 6548 14972 16065 1344 2521 16065 16688 19104 16065 10007 23387 8220 16065 12778 16065 6406 21808 16065 22909 21076 16065 22557 16964 16065 22021 17641 16065 12618 21686 1606...
output:
55444657
result:
ok single line: '55444657'
Test #93:
score: 1
Accepted
time: 3198ms
memory: 160468kb
input:
25000 31277839 5663 7381 2793 13077 20955 344 17945 5699 10530 10454 8137 22690 5483 7192 11673 8886 22205 13853 3692 14737 17727 3213 4524 9511 1979 10215 19056 11737 10541 4125 21818 7758 12771 18843 17029 19885 4948 7600 5351 15311 15766 6046 7503 10941 14787 2590 8928 730 17746 14483 5151 13107 ...
output:
806528898
result:
ok single line: '806528898'
Test #94:
score: 1
Accepted
time: 3916ms
memory: 100260kb
input:
24997 298774555 21443 20224 4469 22594 23394 2281 3123 21844 312 5524 17451 3654 20942 4187 4445 16574 22067 1602 20735 1372 1142 7182 15784 4645 7020 16574 3637 23394 7904 4928 6174 6896 2896 3333 5682 3223 471 1731 3719 1494 1492 4486 24118 2029 1550 18505 5524 3742 517 19859 2878 9031 24834 3281 ...
output:
926363348
result:
ok single line: '926363348'
Test #95:
score: 1
Accepted
time: 455ms
memory: 88576kb
input:
24999 275205785 11331 14986 1 13075 2433 1 12055 8739 1 6221 4216 1 5216 1604 1 9068 629 1 20078 19376 1 6963 2079 1 4281 12892 1 5885 23843 1 1795 19586 1 1855 4596 1 11593 9933 1 12247 11913 1 3637 14967 1 21923 6240 1 18176 23603 1 12828 12835 1 5236 11139 1 23524 13108 1 22410 20347 1 1319 13511...
output:
574977
result:
ok single line: '574977'
Extra Test:
score: 0
Extra Test Passed