QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#588964 | #7884. Campus Partition | HuTao | AC ✓ | 610ms | 332112kb | C++14 | 3.2kb | 2024-09-25 15:27:56 | 2024-09-25 15:27:56 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
namespace FastRead{
char buf[1000005], *s = buf, *t = buf, ch, f;
#define gc() s == t && (t = (s = buf) + fread(buf, 1, 1000000, stdin), s == t) ? EOF : *s ++
template <typename T>
inline void Read(T &x)
{
x = f = 0, ch = gc();
while(ch < '0' || ch > '9')
{
if(ch == '-') f = 1;
ch = gc();
}
while('0' <= ch && ch <= '9') x = x * 10 + ch - 48, ch = gc();
f && (x = -x);
}
};
using FastRead::Read;
typedef long long LL;
const int N = 5e5 + 5;
int n;
int a[N], xx[N], s;
int la[N], ne[N * 2], en[N * 2], idx;
struct Node{
int l, r;
LL v0, v1, t;
}t[N << 5];
int rt[N], pid;
#define mid ((a + b) >> 1)
inline void PushUp(int u)
{
t[u].v0 = max(t[t[u].l].v0, t[t[u].r].v0);
t[u].v1 = max(t[t[u].l].v1, t[t[u].r].v1);
}
inline void Change(int u, LL d)
{
u && (t[u].v0 += d, t[u].v1 += d, t[u].t += d);
}
inline void PushDown(int u)
{
if(t[u].t)
{
Change(t[u].l, t[u].t);
Change(t[u].r, t[u].t);
t[u].t = 0;
}
}
inline void Insert(int &u, int x, LL d, int a = 1, int b = s)
{
if(!u) u = ++ pid;
t[u].v0 = max(t[u].v0, d);
t[u].v1 = max(t[u].v1, d + xx[x]);
if(a == b) return ;
PushDown(u);
if(x <= mid) Insert(t[u].l, x, d, a, mid);
else Insert(t[u].r, x, d, mid + 1, b);
}
inline void Query0(int u, int x, LL &f, int a = 1, int b = s)
{
if(!u) return ;
if(a == b) return void(f = max(f, t[u].v1));
PushDown(u);
if(x <= mid) Query0(t[u].l, x, f, a, mid);
else f = max(f, t[t[u].l].v1), Query0(t[u].r, x, f, mid + 1, b);
}
inline void Query1(int u, int x, LL &f, int a = 1, int b = s)
{
if(!u) return ;
if(a == b) return void(f = max(f, t[u].v0 + xx[x]));
PushDown(u);
if(x <= mid) f = max(f, t[t[u].r].v0 + xx[x]), Query1(t[u].l, x, f, a, mid);
else Query1(t[u].r, x, f, mid + 1, b);
}
inline void Merge(int &u, int v, LL &f, int a = 1, int b = s)
{
if(!u || !v) return void(u |= v);
if(a == b)
{
f = max(f, max(t[u].v0 + t[v].v1, t[v].v0 + t[u].v1));
t[u].v0 = max(t[u].v0, t[v].v0);
t[u].v1 = max(t[u].v1, t[v].v1);
return ;
}
PushDown(u), PushDown(v);
f = max(f, max(t[t[u].r].v0 + t[t[v].l].v1, t[t[v].r].v0 + t[t[u].l].v1));
t[u].v0 = max(t[u].v0, t[v].v0);
t[u].v1 = max(t[u].v1, t[v].v1);
Merge(t[u].l, t[v].l, f, a, mid);
Merge(t[u].r, t[v].r, f, mid + 1, b);
}
inline void Add(int a, int b)
{
ne[ ++ idx] = la[a];
la[a] = idx;
en[idx] = b;
}
inline LL DP(int u, int fa)
{
LL f = 0, f0, s = 0;
for(int i = la[u]; i; i = ne[i])
{
int v = en[i];
if(v != fa)
{
f0 = DP(v, u);
s += f0;
Change(rt[v], -f0);
Merge(rt[u], rt[v], f);
}
}
Query0(rt[u], a[u], f);
Query1(rt[u], a[u], f);
f += s;
Insert(rt[u], a[u], 0);
Change(rt[u], s);
// printf("*%d %d %d %lld\n", u, a[u], xx[a[u]], f);
return f;
}
int main()
{
Read(n);
for(int i = 1; i <= n; i ++ ) Read(a[i]), xx[i] = a[i];
sort(xx + 1, xx + n + 1);
s = unique(xx + 1, xx + n + 1) - xx - 1;
for(int i = 1; i <= n; i ++ ) a[i] = lower_bound(xx + 1, xx + s + 1, a[i]) - xx;
for(int i = 1; i < n; i ++ )
{
int a, b;
Read(a), Read(b);
Add(a, b), Add(b, a);
}
t[0].v0 = t[0].v1 = -1e18;
printf("%lld\n", DP(1, 0));
return 0;
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 12040kb
input:
8 2 5 4 5 3 1 1 3 1 2 1 3 1 4 2 5 2 6 3 7 4 8
output:
8
result:
ok 1 number(s): "8"
Test #2:
score: 0
Accepted
time: 44ms
memory: 83300kb
input:
500000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000...
output:
250000000000000
result:
ok 1 number(s): "250000000000000"
Test #3:
score: 0
Accepted
time: 0ms
memory: 12172kb
input:
10 7 5 6 2 10 10 4 5 4 9 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10
output:
25
result:
ok 1 number(s): "25"
Test #4:
score: 0
Accepted
time: 2ms
memory: 14084kb
input:
10 6 8 7 3 1 3 1 1 9 4 1 5 6 5 7 8 8 4 9 5 5 2 2 4 4 3 3 10
output:
14
result:
ok 1 number(s): "14"
Test #5:
score: 0
Accepted
time: 0ms
memory: 12040kb
input:
10 4 1 5 9 4 6 7 4 6 10 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10
output:
9
result:
ok 1 number(s): "9"
Test #6:
score: 0
Accepted
time: 0ms
memory: 14080kb
input:
10 4 2 2 2 1 5 10 6 7 9 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10
output:
18
result:
ok 1 number(s): "18"
Test #7:
score: 0
Accepted
time: 2ms
memory: 12056kb
input:
10 2 4 5 4 6 8 6 10 3 9 1 2 2 3 3 4 4 5 4 6 2 7 4 8 2 9 4 10
output:
14
result:
ok 1 number(s): "14"
Test #8:
score: 0
Accepted
time: 2ms
memory: 12052kb
input:
10 5 3 1 5 9 5 10 2 6 3 1 2 1 3 2 4 2 5 3 6 3 7 4 8 4 9 5 10
output:
16
result:
ok 1 number(s): "16"
Test #9:
score: 0
Accepted
time: 0ms
memory: 12024kb
input:
10 9 2 10 10 10 10 9 9 1 2 1 2 2 3 1 4 2 5 5 6 3 7 7 8 3 9 1 10
output:
30
result:
ok 1 number(s): "30"
Test #10:
score: 0
Accepted
time: 0ms
memory: 12036kb
input:
10 8 1 3 9 5 3 7 8 8 10 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10
output:
26
result:
ok 1 number(s): "26"
Test #11:
score: 0
Accepted
time: 2ms
memory: 14096kb
input:
10 4 1 9 2 7 2 3 3 2 1 1 6 2 3 6 5 5 4 9 3 3 4 4 8 8 7 7 10
output:
12
result:
ok 1 number(s): "12"
Test #12:
score: 0
Accepted
time: 2ms
memory: 11984kb
input:
10 4 10 7 10 10 3 6 4 2 4 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10
output:
10
result:
ok 1 number(s): "10"
Test #13:
score: 0
Accepted
time: 0ms
memory: 12060kb
input:
10 7 8 4 3 3 1 2 6 3 5 1 2 2 3 3 4 4 5 5 6 6 7 6 8 6 9 6 10
output:
15
result:
ok 1 number(s): "15"
Test #14:
score: 0
Accepted
time: 0ms
memory: 12052kb
input:
10 7 10 6 6 5 8 5 9 1 10 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 3 10
output:
26
result:
ok 1 number(s): "26"
Test #15:
score: 0
Accepted
time: 0ms
memory: 12100kb
input:
10 3 4 5 5 2 1 8 4 1 9 1 2 1 3 2 4 2 5 3 6 3 7 4 8 4 9 5 10
output:
14
result:
ok 1 number(s): "14"
Test #16:
score: 0
Accepted
time: 2ms
memory: 14096kb
input:
10 3 3 1 3 3 7 4 6 2 10 1 2 2 3 1 4 1 5 1 6 5 7 1 8 3 9 8 10
output:
14
result:
ok 1 number(s): "14"
Test #17:
score: 0
Accepted
time: 2ms
memory: 12060kb
input:
100 75 663 978 51 901 936 15 953 5 73 996 29 962 939 932 52 906 79 919 554 927 902 36 110 56 176 95 944 938 916 53 985 37 56 922 48 79 380 887 60 30 480 10 966 12 16 942 79 74 62 10 255 77 84 248 87 19 22 71 57 18 915 80 917 22 606 31 96 51 966 95 88 722 721 1000 14 22 744 75 31 34 70 298 6 922 74 5...
output:
15374
result:
ok 1 number(s): "15374"
Test #18:
score: 0
Accepted
time: 2ms
memory: 12108kb
input:
100 80 60 24 922 68 968 28 29 53 25 28 468 914 41 30 942 53 903 901 61 20 52 32 88 81 66 98 950 11 961 37 900 75 971 101 23 764 981 8 53 913 969 24 6 15 949 99 970 52 976 51 595 397 981 96 44 6 41 903 935 968 74 17 78 44 608 977 911 1000 8 942 918 27 51 806 55 94 923 996 189 166 14 747 472 66 79 48 ...
output:
15348
result:
ok 1 number(s): "15348"
Test #19:
score: 0
Accepted
time: 0ms
memory: 14036kb
input:
100 960 907 926 64 33 66 75 27 68 769 902 931 684 975 903 97 42 7 905 13 46 79 937 93 40 76 11 955 15 39 54 300 968 919 988 66 979 980 169 2 955 952 59 383 52 396 942 64 62 966 59 904 96 924 884 80 823 937 762 915 743 20 998 903 34 713 913 987 49 18 946 541 76 959 717 52 21 73 951 963 4 151 19 12 81...
output:
998
result:
ok 1 number(s): "998"
Test #20:
score: 0
Accepted
time: 0ms
memory: 14036kb
input:
100 129 57 62 25 909 98 55 3 440 842 34 27 933 227 78 18 918 43 956 67 39 703 911 509 78 30 476 29 88 95 927 988 74 69 66 8 969 91 954 983 787 13 5 63 987 504 88 945 72 913 67 363 309 91 51 37 913 57 2 28 612 66 68 64 303 71 949 29 987 949 96 85 901 68 904 992 93 21 6 52 786 71 53 99 907 933 976 865...
output:
9930
result:
ok 1 number(s): "9930"
Test #21:
score: 0
Accepted
time: 2ms
memory: 12052kb
input:
100 54 4 906 997 8 73 35 79 98 402 77 922 310 943 76 5 8 36 462 986 32 32 8 948 37 62 18 56 992 336 669 903 33 85 11 51 2 967 62 976 67 98 840 35 589 920 76 6 17 501 975 407 14 998 84 96 901 9 934 906 289 23 904 990 990 523 86 999 3 92 43 17 95 88 924 68 19 70 73 578 64 14 19 983 397 6 878 510 999 4...
output:
15055
result:
ok 1 number(s): "15055"
Test #22:
score: 0
Accepted
time: 0ms
memory: 11976kb
input:
100 27 919 452 70 74 37 14 11 80 62 844 918 64 12 950 896 986 971 43 7 58 925 15 65 39 27 32 928 64 15 97 987 937 33 999 26 93 986 69 343 85 92 953 917 880 616 221 32 926 8 16 5 961 31 73 303 90 6 57 87 36 935 471 84 12 821 21 989 657 1 340 296 11 97 57 523 91 29 994 927 7 870 918 70 10 68 17 963 96...
output:
14225
result:
ok 1 number(s): "14225"
Test #23:
score: 0
Accepted
time: 0ms
memory: 12168kb
input:
100 18 1 89 931 3 69 95 88 994 83 84 83 641 806 59 912 8 75 15 959 51 86 921 70 66 81 934 35 36 970 3 970 76 981 44 101 93 479 907 7 990 907 33 59 7 45 8 980 38 56 726 88 44 157 5 944 429 924 22 66 87 94 923 942 2 630 68 63 92 44 96 49 970 904 77 5 18 604 49 37 57 3 86 23 904 40 30 984 19 975 367 95...
output:
12436
result:
ok 1 number(s): "12436"
Test #24:
score: 0
Accepted
time: 2ms
memory: 14040kb
input:
100 629 909 904 632 485 339 719 758 724 769 180 866 743 470 103 114 871 523 19 826 224 381 445 978 978 814 729 622 75 899 94 484 108 719 29 897 671 311 421 965 616 381 394 866 681 990 826 65 443 3 495 997 708 956 47 181 756 856 783 518 335 614 4 223 222 63 512 620 685 545 163 740 303 718 935 667 885...
output:
22674
result:
ok 1 number(s): "22674"
Test #25:
score: 0
Accepted
time: 1ms
memory: 11988kb
input:
100 39 270 297 328 551 74 560 69 727 734 175 863 441 680 355 266 868 413 710 91 428 404 269 484 151 827 672 348 569 913 501 853 609 266 364 229 922 383 140 557 3 171 885 237 735 319 685 206 462 950 459 750 562 82 575 240 651 653 536 505 828 569 380 188 755 769 84 583 77 125 389 28 183 898 16 865 366...
output:
17692
result:
ok 1 number(s): "17692"
Test #26:
score: 0
Accepted
time: 1ms
memory: 11976kb
input:
100 961 142 986 617 810 618 105 379 538 698 682 668 242 185 312 609 969 303 506 355 143 940 492 990 323 248 126 371 358 631 804 222 302 621 892 664 572 238 755 854 902 369 376 416 598 135 840 835 993 385 936 696 224 696 998 298 546 155 993 980 424 524 564 857 584 75 655 250 764 897 214 612 960 375 2...
output:
993
result:
ok 1 number(s): "993"
Test #27:
score: 0
Accepted
time: 1ms
memory: 11988kb
input:
100 883 798 675 314 581 353 947 497 349 662 781 769 940 395 564 761 70 384 301 915 859 964 124 688 600 454 773 393 852 156 211 590 995 168 420 995 119 309 962 446 290 863 868 83 948 656 699 976 11 332 197 937 374 414 718 357 442 952 450 967 621 992 236 822 926 973 523 917 155 182 439 196 136 659 856...
output:
23051
result:
ok 1 number(s): "23051"
Test #28:
score: 0
Accepted
time: 1ms
memory: 12020kb
input:
100 294 967 68 602 839 896 788 103 56 819 480 278 742 413 112 401 67 274 801 180 871 795 243 193 476 875 419 119 345 170 322 663 689 522 755 430 665 869 577 743 85 60 359 158 107 985 854 309 30 767 970 691 36 836 949 415 233 454 907 250 114 651 317 299 755 679 94 880 842 466 369 483 17 431 936 563 8...
output:
18295
result:
ok 1 number(s): "18295"
Test #29:
score: 0
Accepted
time: 0ms
memory: 11980kb
input:
100 512 327 460 299 906 440 630 710 163 783 283 379 439 622 261 744 168 164 493 444 587 523 171 699 945 81 169 950 431 183 921 32 190 365 987 762 211 236 1000 335 984 258 850 529 266 506 713 42 561 713 935 932 699 450 669 474 424 251 660 724 311 414 989 967 288 281 962 547 233 942 786 771 602 716 20...
output:
18827
result:
ok 1 number(s): "18827"
Test #30:
score: 0
Accepted
time: 0ms
memory: 12020kb
input:
100 434 792 149 292 869 175 367 828 166 747 790 889 945 832 513 896 973 350 584 708 599 59 98 205 222 502 816 972 116 709 32 697 883 720 323 93 566 795 206 632 371 48 637 900 320 323 868 184 283 852 708 686 553 873 92 829 24 753 821 711 804 369 661 932 926 179 533 214 112 227 419 355 674 896 289 766...
output:
19266
result:
ok 1 number(s): "19266"
Test #31:
score: 0
Accepted
time: 59ms
memory: 84396kb
input:
500000 10 8 8 2 3 7 3 1 1 10 10 8 8 2 2 3 1 9 8 9 10 3 1 1 7 5 4 6 10 9 4 7 7 9 4 2 10 8 8 6 5 9 10 10 4 8 3 2 5 9 5 7 4 5 7 2 1 10 6 1 7 2 9 4 10 2 3 2 6 3 7 10 7 9 2 4 3 4 5 5 6 4 1 2 6 2 5 9 5 9 3 3 7 8 6 7 1 10 6 2 1 2 1 7 10 10 10 10 10 2 2 3 4 6 6 4 4 5 3 6 4 6 1 5 2 3 4 6 8 6 1 4 7 4 10 5 1 3...
output:
1114634
result:
ok 1 number(s): "1114634"
Test #32:
score: 0
Accepted
time: 135ms
memory: 56584kb
input:
500000 10 5 5 4 2 6 4 5 8 8 2 5 4 6 5 2 4 9 5 4 9 8 1 6 6 8 8 10 2 2 1 9 1 5 1 1 1 1 3 3 9 4 5 1 1 9 6 4 3 6 10 2 1 7 5 2 5 3 2 6 5 6 4 1 6 10 3 9 10 2 3 7 8 10 7 3 3 5 8 1 9 9 8 3 7 3 3 3 2 5 2 1 5 10 1 7 3 3 9 1 9 10 3 3 7 4 4 9 4 7 7 7 4 6 7 9 6 10 6 1 1 2 7 3 1 9 6 1 2 6 1 1 5 8 3 3 5 6 3 5 6 9 ...
output:
1034610
result:
ok 1 number(s): "1034610"
Test #33:
score: 0
Accepted
time: 68ms
memory: 89248kb
input:
500000 9 5 7 9 7 9 6 7 9 3 4 2 1 9 9 3 6 6 1 1 7 9 4 5 5 3 1 9 3 3 2 9 4 2 4 10 3 1 7 5 2 6 10 7 4 6 8 7 10 10 5 5 9 6 10 1 8 4 3 8 3 7 3 7 7 3 6 1 9 5 8 6 4 7 5 5 1 9 3 7 5 8 9 10 1 5 3 9 9 3 7 10 4 7 7 8 2 2 7 8 5 9 2 10 5 9 6 1 8 6 4 6 7 8 6 2 6 5 9 9 2 2 2 7 10 1 9 2 9 4 7 4 4 6 10 1 4 8 3 3 7 6...
output:
10
result:
ok 1 number(s): "10"
Test #34:
score: 0
Accepted
time: 57ms
memory: 84344kb
input:
500000 1 4 8 10 10 6 2 4 4 3 10 6 9 5 8 10 9 2 6 6 8 7 3 10 7 6 3 1 8 7 5 2 1 4 1 2 8 3 2 2 5 5 8 8 1 6 9 9 4 6 9 8 10 8 6 3 1 2 9 1 1 4 8 5 3 1 10 2 3 1 1 4 5 10 8 2 7 6 9 5 6 5 6 1 6 2 7 3 9 4 8 2 6 5 2 3 10 10 1 7 1 10 2 6 10 10 10 8 7 3 3 3 6 10 8 6 2 4 10 8 3 2 10 10 9 4 3 6 4 7 3 10 2 6 5 9 4 ...
output:
1106545
result:
ok 1 number(s): "1106545"
Test #35:
score: 0
Accepted
time: 101ms
memory: 85672kb
input:
500000 9 7 7 2 1 7 5 6 7 2 2 9 10 6 2 3 6 10 2 1 7 8 3 9 8 5 7 4 4 8 7 8 5 1 2 7 9 1 10 9 10 6 3 8 3 3 10 8 3 9 10 9 7 10 3 2 2 7 10 9 9 9 4 1 10 3 3 9 1 10 9 1 6 7 9 10 2 1 2 5 8 1 5 9 2 4 6 5 6 10 3 1 5 2 8 4 1 9 3 5 3 3 6 6 7 7 4 2 1 5 6 3 8 10 9 3 2 8 4 2 4 2 2 2 4 6 5 1 6 1 3 3 9 4 2 8 8 1 3 8 ...
output:
991175
result:
ok 1 number(s): "991175"
Test #36:
score: 0
Accepted
time: 75ms
memory: 64004kb
input:
500000 3 6 3 3 2 4 1 2 8 6 8 1 2 2 3 10 6 5 4 6 9 9 2 4 7 4 9 2 9 1 10 4 4 3 9 6 1 2 3 6 4 1 8 8 6 4 2 6 7 5 9 1 6 9 2 2 4 6 2 6 9 3 1 8 6 5 6 3 5 6 8 2 2 8 1 9 2 10 7 1 5 10 2 10 7 9 4 9 3 3 1 5 4 2 9 3 1 8 2 4 4 1 10 7 5 7 10 8 1 2 5 4 1 1 7 8 4 1 7 6 1 8 4 3 7 2 2 6 5 5 5 10 8 2 5 6 7 4 5 9 6 4 5...
output:
975447
result:
ok 1 number(s): "975447"
Test #37:
score: 0
Accepted
time: 86ms
memory: 65728kb
input:
500000 1 9 6 9 1 7 9 2 3 6 4 10 9 6 7 7 1 7 1 1 6 10 6 3 10 9 3 9 10 8 7 6 1 4 10 8 6 4 2 2 7 1 3 5 9 4 3 9 1 5 10 6 7 1 10 1 7 8 9 6 1 8 2 8 3 5 10 10 4 3 1 1 7 1 8 10 4 5 10 7 5 5 3 7 7 1 10 2 6 9 6 4 2 9 10 1 3 7 6 3 6 2 4 9 2 6 10 1 8 1 10 6 9 3 10 1 4 6 10 5 2 7 10 1 9 2 4 6 2 8 10 8 6 6 2 4 1 ...
output:
1040710
result:
ok 1 number(s): "1040710"
Test #38:
score: 0
Accepted
time: 69ms
memory: 84676kb
input:
500000 6 6 10 1 4 1 3 6 5 3 9 7 2 10 8 5 3 9 6 1 8 8 4 5 2 9 6 2 8 2 10 10 1 4 10 9 7 6 5 6 10 3 1 4 2 2 5 5 3 7 8 4 5 10 1 7 8 3 2 1 5 3 8 8 1 2 9 2 8 3 10 7 1 6 10 8 10 1 4 6 10 2 2 4 5 8 7 10 10 2 9 9 3 6 5 8 9 7 5 2 3 6 5 2 9 2 8 9 9 7 8 10 9 9 8 6 9 5 7 7 5 9 4 8 10 4 7 8 5 2 8 2 2 4 10 7 8 5 2...
output:
1116784
result:
ok 1 number(s): "1116784"
Test #39:
score: 0
Accepted
time: 138ms
memory: 56608kb
input:
500000 2 4 10 4 3 4 8 3 6 6 8 6 1 3 3 2 5 6 2 6 2 9 5 6 8 5 7 5 4 1 8 7 6 3 5 8 8 2 3 7 3 10 5 5 3 1 2 10 7 4 10 3 7 2 6 10 3 3 4 2 10 6 1 4 6 6 7 6 5 10 6 10 9 8 7 3 8 6 9 3 10 5 10 9 7 7 9 6 8 5 3 6 5 3 5 10 10 7 5 7 8 1 5 5 9 7 2 4 8 2 4 4 6 1 2 4 4 10 9 9 2 3 10 2 7 6 7 10 10 9 10 5 7 3 4 10 3 4...
output:
1033780
result:
ok 1 number(s): "1033780"
Test #40:
score: 0
Accepted
time: 65ms
memory: 89124kb
input:
500000 2 6 8 7 10 1 1 5 6 7 2 3 2 9 7 10 8 1 2 6 5 3 3 9 4 8 1 1 7 7 1 1 5 10 6 6 5 9 2 8 5 2 8 6 4 2 2 9 8 3 9 6 10 7 8 10 5 4 1 5 7 7 7 1 4 5 9 3 8 7 7 6 3 3 1 5 4 4 10 10 3 8 9 10 3 2 7 7 3 2 10 7 1 5 9 3 2 2 3 9 10 6 6 9 5 4 8 2 10 6 8 3 7 6 7 3 7 2 4 4 1 1 9 7 9 1 5 5 10 5 2 3 8 6 1 8 7 8 5 8 3...
output:
10
result:
ok 1 number(s): "10"
Test #41:
score: 0
Accepted
time: 67ms
memory: 84520kb
input:
500000 7 6 9 6 8 9 7 6 10 8 4 2 3 3 3 6 10 2 8 1 9 9 5 3 9 1 4 1 9 6 3 8 8 2 1 2 5 3 3 7 2 7 6 5 7 10 1 4 1 9 2 1 6 5 2 1 10 3 9 8 6 10 2 7 3 6 6 5 4 8 1 5 1 3 8 5 2 5 1 7 9 5 8 10 10 7 6 7 7 5 5 3 3 8 1 5 8 10 10 5 5 10 6 2 7 9 4 4 6 1 4 3 6 9 10 2 4 5 8 2 10 9 6 4 6 8 10 9 4 7 3 1 4 10 2 1 4 6 6 1...
output:
835988
result:
ok 1 number(s): "835988"
Test #42:
score: 0
Accepted
time: 74ms
memory: 83292kb
input:
500000 7 5 3 9 5 10 10 7 1 1 8 2 2 2 6 10 10 9 1 3 9 5 3 10 5 1 1 8 2 10 10 9 7 5 7 9 2 5 9 8 4 8 10 6 8 5 2 3 4 2 5 4 9 9 4 5 2 9 6 1 4 7 5 9 2 6 2 2 1 5 7 2 5 6 4 7 10 6 2 9 3 1 2 1 10 1 8 8 5 9 9 4 1 9 5 4 4 5 10 2 1 5 6 1 1 8 8 7 10 1 7 2 8 2 6 10 9 1 6 5 9 7 2 6 7 5 4 1 4 4 1 3 9 9 7 8 4 10 10 ...
output:
1101336
result:
ok 1 number(s): "1101336"
Test #43:
score: 0
Accepted
time: 86ms
memory: 63920kb
input:
500000 1 7 4 7 8 7 3 3 1 2 3 5 3 6 10 7 1 4 7 9 8 7 6 8 7 10 1 2 4 9 4 8 3 8 2 1 3 6 10 2 1 6 8 2 9 7 9 8 5 1 1 3 5 1 6 4 7 6 8 4 7 10 5 1 7 9 8 4 4 6 7 2 8 1 2 8 6 10 7 2 8 4 1 6 8 6 1 8 6 10 6 5 4 1 5 6 2 5 1 2 7 10 10 10 3 3 4 5 8 8 5 10 9 6 7 9 1 2 4 1 8 5 1 3 9 5 10 7 4 10 3 6 4 5 6 3 3 8 9 6 1...
output:
975688
result:
ok 1 number(s): "975688"
Test #44:
score: 0
Accepted
time: 82ms
memory: 65712kb
input:
500000 1 5 2 6 8 5 9 4 9 5 7 2 4 2 5 9 5 8 7 4 2 3 2 7 5 2 2 9 6 3 10 9 2 8 5 7 9 2 9 3 4 9 8 9 10 8 8 7 4 7 6 2 10 5 10 6 5 1 9 1 10 2 10 2 10 6 6 5 1 7 2 1 10 1 9 10 9 5 10 9 2 3 9 2 3 1 3 9 10 3 10 1 4 8 1 7 4 9 7 8 2 5 6 3 7 6 10 8 7 3 7 3 6 5 3 8 2 4 8 1 7 5 2 8 6 2 2 4 8 5 10 8 1 8 7 7 4 5 2 1...
output:
1040051
result:
ok 1 number(s): "1040051"
Test #45:
score: 0
Accepted
time: 176ms
memory: 87956kb
input:
500000 671446893 999999968 51 44 79 94 661147822 999999966 8 999999966 72 999999967 999999904 42 61 73 80 59 999999985 999999948 999999984 28 51 999999934 71 95071468 40 1 36 999999924 19 92 49 999999934 56 95 48 94 999999913 28 68 999999923 437987080 16 435239959 21 50 57 80 999999920 33 999999953 ...
output:
82707115599682
result:
ok 1 number(s): "82707115599682"
Test #46:
score: 0
Accepted
time: 403ms
memory: 191928kb
input:
500000 68 58 999999974 674281208 999999995 592280624 35 999999962 99 999999979 80 305176676 999999948 999999900 41 24 999999940 999999984 921032777 999999955 999999906 23 512486613 36 999999978 64 32 35 999999943 75 41 957672754 61 79 21 999999960 524521835 880774101 10 67 42 23 46 67 55 999999916 8...
output:
77817006445746
result:
ok 1 number(s): "77817006445746"
Test #47:
score: 0
Accepted
time: 246ms
memory: 291728kb
input:
500000 84 999999912 99 69 999999935 93 66 337020190 748441784 24 8 999999955 774558004 651332309 20 88 999999990 75 179549676 999999995 999999906 86 96 92 141154122 5 999999922 1 999999961 318637609 999999930 869872622 40 11 999999917 999999915 501709507 42 96 38 999999926 532383531 765748726 85 999...
output:
1000000000
result:
ok 1 number(s): "1000000000"
Test #48:
score: 0
Accepted
time: 197ms
memory: 167792kb
input:
500000 999999954 80 1000000000 999999908 999999918 36 7 100 24 15 999999948 712791073 891971498 64 999999999 999999939 18 999999954 7 36 27557007 81 451210650 999999992 999999904 999999969 14 68 13 999999938 292608121 999999983 999999952 45 95 84 743738396 61 48 10 999999945 55 999999970 2 43 10 999...
output:
49963649736824
result:
ok 1 number(s): "49963649736824"
Test #49:
score: 0
Accepted
time: 232ms
memory: 149008kb
input:
500000 27 36 57 83 60 999999979 999999905 90617781 999999902 999999959 999999956 101 449576479 56 496560814 235180589 12 81 999999906 43 87 43 6 989535749 13 999999910 39 34 32 88 31 93 65 99898122 60 39 38 999999912 45 805874292 437048912 66 22 52 999999982 999999906 100 706192219 589835376 10 9999...
output:
79497172996062
result:
ok 1 number(s): "79497172996062"
Test #50:
score: 0
Accepted
time: 279ms
memory: 216488kb
input:
500000 43 999999923 999999991 1 44 23 999999936 47 50 999999972 18 999999932 61 999999925 48 999999965 999999972 72 999999962 15 591701516 999999937 1 82 431708492 87 999999940 68 787941553 999999903 54 1000000000 11 999999955 57 320096204 999999924 99 835271344 999999919 999999915 32 999999916 70 9...
output:
77708228800725
result:
ok 1 number(s): "77708228800725"
Test #51:
score: 0
Accepted
time: 297ms
memory: 189532kb
input:
500000 999999913 80 15 75 16 68 500061117 999999930 999999996 999999927 26 954373821 36 37419537 27 763484157 1000000000 863453930 944257145 999999954 6194379 1000000000 999999995 999999971 7 50 33 35 59 53 999999931 77 999999922 22 999999921 999999971 11 51 48 25 423693530 999999930 81 88 60 68 999...
output:
78356343600979
result:
ok 1 number(s): "78356343600979"
Test #52:
score: 0
Accepted
time: 356ms
memory: 114176kb
input:
500000 455032326 401218876 609385748 923415420 806357807 909519517 748395834 409977495 574672612 394465494 803672839 963292991 775179857 829545840 968783397 25453644 942270403 851807670 154232741 630776475 790507308 873418550 515983996 199955342 798797475 12282947 630040064 935018890 89023202 536948...
output:
101241324421739
result:
ok 1 number(s): "101241324421739"
Test #53:
score: 0
Accepted
time: 610ms
memory: 285820kb
input:
500000 212519023 813342135 936741483 99544261 628061117 189317816 627002991 612081298 15666417 108469296 69291344 725785243 276420008 61159837 260707287 402252439 506135667 780033681 907017469 795703699 585833814 354804018 393441905 328890989 547824201 274920633 771093781 642718297 486832571 2256665...
output:
93847418818405
result:
ok 1 number(s): "93847418818405"
Test #54:
score: 0
Accepted
time: 512ms
memory: 332112kb
input:
500000 264973016 80241202 118873026 275673102 449764427 28924627 360385955 519217805 601884414 672729994 744975258 488277495 217851648 442516938 552631177 484083939 70000931 118325101 809545301 370696330 526384512 395997999 125675622 312602443 591818224 687301422 61890603 55450408 739417747 64954353...
output:
999998916
result:
ok 1 number(s): "999998916"
Test #55:
score: 0
Accepted
time: 419ms
memory: 209620kb
input:
500000 317427008 52172973 741196058 451801944 126243545 13755630 798801623 571578504 42878219 386733795 10593764 250769747 864315992 674130936 844555067 565915438 633866196 191775305 857297324 385880450 321711017 582416171 857909340 736505386 930779542 804714916 202944321 908374007 137227116 4834859...
output:
54218525718737
result:
ok 1 number(s): "54218525718737"
Test #56:
score: 0
Accepted
time: 408ms
memory: 129200kb
input:
500000 369881001 464296231 923327601 478187681 242914152 853362441 532184587 68649603 483872024 656027197 686277677 718294704 365556143 760520741 431446253 382905722 492698756 120001317 610082052 255840377 412004819 63801640 735367249 720216840 679806269 217095705 343998038 321106118 240069189 90736...
output:
99535724184591
result:
ok 1 number(s): "99535724184591"
Test #57:
score: 0
Accepted
time: 552ms
memory: 301664kb
input:
500000 422334994 731195298 250683336 654316522 359584758 692969252 265567552 975786110 219833126 370030999 951896183 626011148 12020487 141877842 573627039 464737221 911339828 753260033 512609884 125800304 207331325 104995620 467600967 144119783 723800291 334509199 929762156 28805525 637878558 74130...
output:
89395808186636
result:
ok 1 number(s): "89395808186636"
Test #58:
score: 0
Accepted
time: 490ms
memory: 266552kb
input:
500000 474788986 848351261 432814880 830445364 181288068 677800255 144174708 323114105 660826931 789067504 922547393 388503400 513260638 373491839 865550929 546568721 475205093 386518749 560361908 846017128 2657831 291413793 345058876 273055429 767794314 746889988 70815874 586761829 330655222 724990...
output:
94380124703125
result:
ok 1 number(s): "94380124703125"
Test #59:
score: 0
Accepted
time: 2ms
memory: 12048kb
input:
1 1000000000
output:
0
result:
ok 1 number(s): "0"
Extra Test:
score: 0
Extra Test Passed