QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#876848#7884. Campus Partitionbamboo123RE 1131ms842468kbC++143.1kb2025-01-31 13:56:222025-01-31 13:56:25

Judging History

This is the latest submission verdict.

  • [2025-01-31 13:56:25]
  • Judged
  • Verdict: RE
  • Time: 1131ms
  • Memory: 842468kb
  • [2025-01-31 13:56:22]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
const int maxn = 5e5 + 5;
int n, a[maxn], ls[maxn], tot;
struct node {
	int l, r, mx, mx1;
};
int rt[maxn];
struct Segtree {
	node tr[maxn * 100];
	int tag[maxn * 100], tot;
	void pushup(int t) {
		tr[t].mx = max(tr[tr[t].l].mx, tr[tr[t].r].mx);
		tr[t].mx1 = max(tr[tr[t].l].mx1, tr[tr[t].r].mx1);
	}
	void addtag(int t, int val) {
		tr[t].mx += val;
		tr[t].mx1 += val;
		tag[t] += val;
	}
	void pushdown(int t) {
		if(tr[t].l)
			addtag(tr[t].l, tag[t]);
		if(tr[t].r)
			addtag(tr[t].r, tag[t]);
		tag[t] = 0;
	}
	int modify(int l, int r, int pos, int t, int val) {
		if(!t)
			t = ++tot;
		if(l == r) {
			tr[t].mx = val;
			tr[t].mx1 = val + ls[l];
			return t;
		}
		pushdown(t);
		int mid = l + r >> 1;
		if(pos <= mid)
			tr[t].l = modify(l, mid, pos, tr[t].l, val);
		else
			tr[t].r = modify(mid + 1, r, pos, tr[t].r, val);
		pushup(t);
		return t;
	}
	int mrg(int l, int r, int x, int y, int &res, int mxx, int mxy, int v1, int v2) {
//		if(v1 < 0 || v2 < 0)
//			exit(1);
//		if(x && tr[x].mx < 0)
//			exit(1);
//		if(y && tr[y].mx < 0)	
//			exit(1);
	//	cout << l << " " << r << " " << mxx << " " << mxy << " " << tr[x].mx << " " << tr[y].mx << endl;
		if(!x) {
			res = max(res, tr[y].mx1 + mxx);
			addtag(y, v2);
			return y;
		}
		if(!y) {
			res = max(res, tr[x].mx1 + mxy);
			addtag(x, v1);
			return x;
		}
		if(l == r) {
			res = max(res, max(max(mxx + tr[y].mx, mxy + tr[x].mx), tr[x].mx + tr[y].mx) + ls[l]);
			tr[x].mx = max(tr[x].mx + v1, tr[y].mx + v2);
			tr[x].mx1 = tr[x].mx + ls[l];
			return x;
		}
		int mid = l + r >> 1;
		pushdown(x), pushdown(y);
		tr[x].l = mrg(l, mid, tr[x].l, tr[y].l, res, max(mxx, tr[tr[x].r].mx), max(mxy, tr[tr[y].r].mx), v1, v2);
		tr[x].r = mrg(mid + 1, r, tr[x].r, tr[y].r, res, mxx, mxy, v1, v2);
		pushup(x);
		return x;
	}
	int query(int l, int r, int pos, int t) {
		if(l == r)
			return tr[t].mx;
		int mid = l + r >> 1;
		pushdown(t);
		if(pos <= mid)
			return query(l, mid, pos, tr[t].l);
		else
			return query(mid + 1, r, pos, tr[t].r);
	}
} tree;
int g[maxn];
vector<int> e[maxn];
void dfs(int u, int fa) {
	int s = 0;
	rt[u] = tree.modify(0, n, a[u], rt[u], 0);
	tree.modify(0, n, 0, rt[u], 0);
	for (int i = 0; i < e[u].size(); i++) {
		int v = e[u][i];
		if(v == fa)
			continue;
		dfs(v, u);
		if(g[v] < 0 || s < 0)
			exit(1);
		rt[u] = tree.mrg(0, n, rt[u], rt[v], g[u], -1e15, -1e15, g[v], s);
		s += g[v];
		rt[u] = tree.modify(0, n, 0, rt[u], g[u]);
	//	cout << u << " " << v << " " << lst << " " << g[u] << " " << tree.query(0, n, 0, rt[u]) << endl;
	}
//	cout << u << " " << g[u] << endl;
}
signed main() {
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> a[i], ls[i] = a[i];
	sort(ls + 1, ls + n + 1);
	for (int i = 1; i <= n; i++)
		a[i] = lower_bound(ls + 1, ls + n + 1, a[i]) - ls;
	for (int i = 1; i < n; i++) {
		int x, y;
		cin >> x >> y;
		e[x].push_back(y);
		e[y].push_back(x);
	}
	tree.tr[0].mx = tree.tr[0].mx1 = -1e15;
	dfs(1, 0);
	cout << g[1] << endl;
	return 0;
}
/*
8
2 5 4 5 3 1 1 3
1 2
1 3
1 4
2 5
2 6
3 7
4 8
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 24624kb

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: 746ms
memory: 513156kb

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: 2ms
memory: 23692kb

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: 1ms
memory: 24344kb

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: 1ms
memory: 25180kb

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: 2ms
memory: 25276kb

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: 1ms
memory: 24844kb

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: 0ms
memory: 23816kb

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: 2ms
memory: 24556kb

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: 3ms
memory: 24912kb

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: 3ms
memory: 23824kb

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: 23584kb

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: 1ms
memory: 23628kb

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: 25584kb

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: 1ms
memory: 24604kb

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: 0ms
memory: 24172kb

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: 0ms
memory: 23972kb

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: 0ms
memory: 24120kb

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: 2ms
memory: 25160kb

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: 2ms
memory: 25572kb

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: 25136kb

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: 5ms
memory: 23952kb

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: 1ms
memory: 25112kb

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: 1ms
memory: 24248kb

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: 25148kb

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: 2ms
memory: 24664kb

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: 2ms
memory: 25340kb

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: 2ms
memory: 23864kb

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: 1ms
memory: 23928kb

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: 3ms
memory: 24132kb

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: 909ms
memory: 814548kb

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: 1115ms
memory: 760440kb

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: 708ms
memory: 762512kb

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: 886ms
memory: 812816kb

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: 1009ms
memory: 792124kb

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: 808ms
memory: 760336kb

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: 851ms
memory: 772988kb

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: 897ms
memory: 814836kb

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: 1131ms
memory: 761944kb

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: 705ms
memory: 760552kb

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: 861ms
memory: 802284kb

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: 899ms
memory: 808488kb

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: 816ms
memory: 761232kb

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: 847ms
memory: 770940kb

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: 1082ms
memory: 842468kb

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: -100
Runtime Error

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:


result: