QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#799383#9854. Find the MaximumSGColinAC ✓27ms21932kbC++201.1kb2024-12-05 12:39:352024-12-05 12:39:35

Judging History

你现在查看的是最新测评结果

  • [2024-12-05 12:39:35]
  • 评测
  • 测评结果:AC
  • 用时:27ms
  • 内存:21932kb
  • [2024-12-05 12:39:35]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long double ld;

inline int rd() {
	int x = 0;
	bool f = 0;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) f |= (c == '-');
	for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
	return f ? -x : x;
}

#define N 100007

#define fr first
#define sc second
#define mp make_pair
#define pii pair<int, int>

ld a[N], ans = 0.0;

vector<int> e[N];

inline ld sqr(ld x) {return x * x;}

void dfs(int u, int fa) {
	ld mx = 0, mn = 0;
	for (auto v : e[u])
		if (v != fa) {
			dfs(v, u);
			ans = max(ans, sqr((a[u] + a[v]) / 2));
			if (u != 1) ans = max(ans, sqr((a[u] + a[fa] + a[v]) / 3));
			ans = max(ans, sqr((a[u] + a[v] + mx) / 3));
			ans = max(ans, sqr((a[u] + a[v] + mn) / 3));
			mx = max(mx, a[v]);
			mn = min(mn, a[v]);
		}
}

int main() {
	int n = rd();
	for (int i = 1; i <= n; ++i) a[i] = rd();
	for (int i = 1; i < n; ++i) {
		int u = rd(), v = rd();
		e[u].push_back(v); e[v].push_back(u);
	}
	dfs(1, 1);
	printf("%.6Lf\n", ans / 4.0);
	return 0;
}

这程序好像有点Bug,我给组数据试试?

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 5884kb

input:

2
3 2
1 2

output:

1.562500

result:

ok Accept!

Test #2:

score: 0
Accepted
time: 15ms
memory: 10944kb

input:

100000
92267 92164 51606 26141 24879 -67311 -25229 -65514 77800 -9213 -65704 -59430 21111 94890 39508 -13162 58661 34181 -86666 -29450 1588 -18722 -75565 15211 28028 -39385 -97517 -85584 -9097 13770 31381 -21566 37697 19483 74839 -31752 -10681 -93336 -69242 46591 -76345 -15194 69484 34351 -121 91430...

output:

2372729047.111111

result:

ok Accept!

Test #3:

score: 0
Accepted
time: 4ms
memory: 10864kb

input:

100000
20036 58982 -54696 2627 -93016 66529 34860 -1438 49628 -5386 70370 25036 -67285 -70258 27348 59316 -67699 18718 36124 -37387 80279 1315 -18946 84067 -12213 -72069 79001 52586 -19913 2496 19794 54569 -96918 -31049 554 -33785 44773 -21375 -4087 -87453 5134 -84574 -53715 47515 20914 4808 -50228 ...

output:

1344835584.000000

result:

ok Accept!

Test #4:

score: 0
Accepted
time: 11ms
memory: 10832kb

input:

100000
-63335 57151 81047 -66724 -99858 60401 62337 -8832 59071 -33606 -78529 97304 -22976 -42931 -75137 -75522 59687 -94876 -86564 -91692 -96959 -89699 -64180 -47471 -33475 -59840 20255 -58826 73842 99259 6635 7286 -96421 73755 -74049 -2383 59482 51168 89847 79514 -68221 -58318 4767 -54946 5226 219...

output:

1926127285.444444

result:

ok Accept!

Test #5:

score: 0
Accepted
time: 1ms
memory: 5956kb

input:

2
-100000 -11453
1 2

output:

776360700.562500

result:

ok Accept!

Test #6:

score: 0
Accepted
time: 1ms
memory: 5960kb

input:

2
82384 -97348
1 2

output:

13995081.000000

result:

ok Accept!

Test #7:

score: 0
Accepted
time: 1ms
memory: 5968kb

input:

2
1 93748
1 2

output:

549304687.562500

result:

ok Accept!

Test #8:

score: 0
Accepted
time: 0ms
memory: 5856kb

input:

3
83355 93748 -94895
1 2
1 3

output:

1960342038.062500

result:

ok Accept!

Test #9:

score: 0
Accepted
time: 0ms
memory: 6016kb

input:

3
-83355 94895 93748
1 3
1 2

output:

307932304.000000

result:

ok Accept!

Test #10:

score: 0
Accepted
time: 20ms
memory: 11060kb

input:

100000
65078 -53832 -63843 76930 -63522 84693 -62280 31020 -67336 32124 -91555 -76670 -2197 59136 -48461 40126 -63002 -48118 90820 -5786 -19015 -42347 80679 43065 25409 -73676 20200 45423 -96119 68024 83729 -64148 81295 -23731 75516 5371 -77964 -43119 -75917 -97067 58718 -77652 45231 -52118 -42723 -...

output:

2496201444.000000

result:

ok Accept!

Test #11:

score: 0
Accepted
time: 21ms
memory: 21764kb

input:

100000
12309 -49177 -83247 -78048 -79211 59252 7079 -76095 64871 17835 32114 -3184 -95315 83200 11241 55870 -20091 25106 74869 -98957 35748 -41333 -94536 -55133 90565 -57318 214 -67120 -87282 96730 -44936 -62848 66414 3078 83167 12580 -64854 15073 5510 86449 -91611 -72381 14514 -32238 72774 -60290 -...

output:

2481310062.562500

result:

ok Accept!

Test #12:

score: 0
Accepted
time: 17ms
memory: 21932kb

input:

100000
-59146 2886 85605 -28688 -7542 7985 -88204 5131 -90293 -24530 -14902 32285 -58674 99882 -14431 45342 12947 -27974 72676 13004 -24857 -7030 -17256 84049 -15396 30399 59000 -81817 -28792 -13940 11943 27556 -54255 -13134 -74902 19813 -5458 70117 45120 -49229 50983 -23628 -49257 -84939 -68777 -38...

output:

2481036100.000000

result:

ok Accept!

Test #13:

score: 0
Accepted
time: 22ms
memory: 21760kb

input:

100000
-2 0 -1 -1 0 -1 0 -1 0 0 -1 -2 -1 -2 -1 -2 -1 0 -1 0 0 0 0 0 -2 0 -2 -2 0 0 -2 0 -2 -2 -1 0 -2 0 -2 -2 -2 0 -1 0 -2 0 -2 0 -1 -2 -1 -2 -2 0 -2 -2 -1 0 -2 0 -1 -2 0 0 0 -2 -1 -1 0 -2 -2 -2 -1 -2 -2 -1 -2 -1 -2 0 -2 -2 -2 -2 0 -2 -2 0 -2 -2 -2 0 -1 -1 0 -2 0 0 -2 -1 -1 0 0 0 -2 -1 0 0 0 0 0 -1 ...

output:

624987500.062500

result:

ok Accept!

Test #14:

score: 0
Accepted
time: 27ms
memory: 21804kb

input:

100000
-1 -2 -1 -2 -2 -1 -1 0 0 -1 -1 -2 -2 -1 -1 0 -1 0 0 -2 0 -1 -1 -1 -1 -1 -2 -1 0 -2 -1 -1 -1 -2 -2 0 -2 -1 -2 -2 -2 -2 -1 -2 0 -2 0 -2 -1 -1 -2 -1 -1 0 -1 0 -1 0 0 -2 -1 -2 0 0 0 0 -1 0 0 -2 -2 0 -1 -1 -1 0 0 -1 -2 0 -1 -1 -1 0 -2 -1 -2 -1 -1 -2 -2 0 0 0 -1 0 -1 0 -2 -2 -2 0 0 -1 -2 -1 -1 0 0 ...

output:

624962500.562500

result:

ok Accept!

Test #15:

score: 0
Accepted
time: 15ms
memory: 16412kb

input:

100000
-2 -2 0 -1 -1 -1 -2 0 -2 -2 0 -1 0 -1 -1 -1 0 -1 -2 -1 0 0 0 -2 0 -2 -2 -1 -1 0 -2 -1 -1 0 -2 0 0 -2 -2 -2 0 -2 0 -1 -1 -2 0 0 0 -2 -1 0 -2 0 -2 0 -2 -2 -2 -1 -2 0 -2 0 -2 -2 -2 -1 0 0 -2 -2 -1 -1 -2 -2 0 -1 -2 -1 0 0 -2 -1 -2 -1 -1 0 -2 0 0 -1 -1 -2 0 -2 -1 -2 0 0 -2 0 0 -2 -1 0 -2 0 -1 -1 0...

output:

1111111111.111111

result:

ok Accept!

Test #16:

score: 0
Accepted
time: 20ms
memory: 16460kb

input:

100000
0 -9 -3 -8 0 -2 -2 0 -9 -3 -9 -6 -4 -5 -2 -7 -8 -9 -3 -8 -6 -2 -8 -7 -7 -3 -5 -9 -6 -4 -7 -7 -1 -3 -6 0 -6 -9 -1 -4 -5 -3 -2 -6 -9 -5 -6 -5 0 -9 -9 -1 -9 -8 -8 -2 -8 -8 -7 -6 -8 0 -9 -9 -1 -5 -4 -9 -3 -6 -6 -8 -2 0 0 0 -6 -8 -1 -2 -2 -5 -2 -6 -8 -8 -3 -6 -3 -4 -3 0 -1 -4 -3 -3 -3 -2 0 -5 -5 -...

output:

1111044445.444444

result:

ok Accept!

Test #17:

score: 0
Accepted
time: 19ms
memory: 14672kb

input:

99999
9 2 4 3 9 5 8 1 7 6 7 3 9 2 6 0 6 8 0 5 7 8 6 8 6 8 5 4 3 1 4 1 6 1 9 3 7 5 7 5 9 3 4 8 8 3 5 9 6 6 7 1 0 7 6 2 0 1 3 9 1 5 0 4 4 2 2 3 7 6 3 4 5 6 0 3 8 1 0 6 2 0 9 4 6 4 2 3 1 5 0 9 8 9 8 9 4 5 9 7 4 4 9 2 8 0 6 0 6 1 2 0 2 5 4 1 9 0 5 4 2 4 1 8 5 1 2 9 9 5 9 9 9 7 3 6 8 7 2 1 8 1 3 2 8 6 9 ...

output:

1110977781.777778

result:

ok Accept!

Test #18:

score: 0
Accepted
time: 12ms
memory: 14660kb

input:

99999
4 5 2 6 7 6 4 7 0 9 0 6 7 3 4 9 6 0 2 4 8 8 5 3 0 4 3 0 3 3 3 4 3 2 8 7 5 1 1 7 6 9 7 4 1 6 8 7 1 9 2 7 9 8 9 9 4 6 5 3 4 1 9 4 9 3 8 9 6 6 0 1 3 0 4 4 1 2 7 4 8 6 8 1 9 6 7 9 6 1 9 2 7 4 4 2 5 4 8 4 5 8 2 3 4 2 7 8 1 6 0 5 5 5 5 2 3 2 1 0 9 0 5 0 5 0 6 8 6 5 8 2 9 2 5 2 8 0 1 7 1 7 0 1 7 3 2 ...

output:

2499375039.062500

result:

ok Accept!

Test #19:

score: 0
Accepted
time: 22ms
memory: 14500kb

input:

99999
-6 -3 0 -1 -7 -3 -7 -2 -1 -7 -5 -8 -7 0 -3 -7 0 -5 -1 -9 -9 -4 -3 -7 -9 -1 -7 -7 -3 -7 -6 -5 -4 0 -3 -7 -7 -1 -8 -8 -3 -3 -8 -4 -9 -3 0 -5 -8 -2 -6 -4 -4 -9 -6 -4 -6 -5 0 -5 -7 -9 -1 -8 0 -6 -1 -5 -1 0 -1 -3 -8 -7 -1 -8 -8 -5 -4 -1 -6 -4 -4 -2 -6 -7 -5 -8 -6 -2 -2 -4 -5 -7 -5 0 -5 -2 0 -4 -9 -...

output:

1110900010.027778

result:

ok Accept!

Test #20:

score: 0
Accepted
time: 11ms
memory: 14664kb

input:

99999
-679 -579 -183 -608 -433 -165 -457 -817 -530 -31 -981 -161 -477 -359 -367 -762 -587 -60 -760 -119 -199 -141 -817 -945 -114 -772 -119 -735 -12 -970 -959 -546 -546 -775 -703 -744 -625 -756 -967 -347 -871 -535 -55 -877 -136 -458 -886 -199 -509 -717 -459 -212 -620 -498 -964 -598 -9 -105 -426 -441 ...

output:

1105396256.250000

result:

ok Accept!

Test #21:

score: 0
Accepted
time: 20ms
memory: 14664kb

input:

99999
-612 -504 -662 -418 -415 -735 -917 -424 -759 -883 -267 -581 -891 -5 -759 -384 -594 -495 -31 -949 -171 -36 -605 -340 -43 -896 -724 -207 -96 -331 -868 -933 -999 -507 -497 -385 -176 -315 -77 -530 -816 -101 -485 -3 -354 -643 -704 -336 -691 -884 99928 -664 -239 -458 -369 -388 -180 -361 -258 -802 -8...

output:

1104099984.000000

result:

ok Accept!

Test #22:

score: 0
Accepted
time: 14ms
memory: 14608kb

input:

99999
-26280 -16038 -16938 -3609 -128 -3795 -9891 -2132 -15343 -6637 -24086 -6476 -15506 -19138 -25703 -28822 -25054 -21552 -20995 -9402 -29495 -8167 -5868 -1571 -4752 -21887 -26198 -21824 -21284 -9056 -21589 -21434 -8052 -29352 -10776 -9013 -19347 -25136 -12609 -2937 -13058 -10250 -1214 -12480 -175...

output:

981652448.444444

result:

ok Accept!

Test #23:

score: 0
Accepted
time: 0ms
memory: 5988kb

input:

999
78 3 7 -13 53 14 39 57 -39 64 67 -13 -6 -38 12 -37 92 -10 -46 -84 71 -73 -29 -11 -24 -86 -7 0 -4 42 69 60 23 4 57 96 90 -30 -63 -63 0 -17 -79 -40 56 22 36 -44 -84 -49 65 -41 40 10 -94 5 -56 90 30 -79 -66 18 78 -93 -74 -18 21 95 -1 14 44 -21 -59 23 95 -49 5 76 67 -79 -27 70 73 -21 66 80 85 -37 -6...

output:

2376.562500

result:

ok Accept!

Test #24:

score: 0
Accepted
time: 19ms
memory: 14668kb

input:

99999
7 8 6 -1 -2 -4 -7 -4 -8 6 2 -8 6 1 2 -5 -8 -1 -5 -2 9 -2 -6 -8 -5 -4 7 -8 1 1 4 -8 5 1 7 2 3 7 -2 4 7 -5 7 3 -8 6 -9 4 -2 -4 -5 6 8 0 -3 -5 -9 7 5 5 -6 -8 -3 2 5 9 7 -5 3 0 0 -6 2 -6 5 8 3 -8 -6 7 -7 0 3 -8 -5 6 6 9 -6 0 7 -5 -3 4 6 7 -7 -6 -9 3 -9 -4 -5 8 -1 5 2 3 7 5 -3 -8 -1 -7 2 -3 0 6 7 1...

output:

20.250000

result:

ok Accept!

Test #25:

score: 0
Accepted
time: 16ms
memory: 11952kb

input:

68954
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

output:

0.000000

result:

ok Accept!

Test #26:

score: 0
Accepted
time: 1ms
memory: 5960kb

input:

2
-100000 -100000
1 2

output:

2500000000.000000

result:

ok Accept!

Test #27:

score: 0
Accepted
time: 0ms
memory: 6020kb

input:

3
100000 100000 100000
1 2
2 3

output:

2500000000.000000

result:

ok Accept!

Test #28:

score: 0
Accepted
time: 1ms
memory: 3972kb

input:

3
99999 100000 99999
1 2
2 3

output:

2499975000.062500

result:

ok Accept!

Test #29:

score: 0
Accepted
time: 1ms
memory: 3964kb

input:

2
-100000 100000
1 2

output:

0.000000

result:

ok Accept!

Extra Test:

score: 0
Extra Test Passed