QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#324311#8242. V-Diagramucup-team484#WA 152ms4128kbC++171013b2024-02-10 17:45:202024-02-10 17:45:21

Judging History

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

  • [2024-02-10 17:45:21]
  • 评测
  • 测评结果:WA
  • 用时:152ms
  • 内存:4128kb
  • [2024-02-10 17:45:20]
  • 提交

answer

#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const int N = 1e6 + 5;

void solve() {
	int n; cin >> n;
	vector<int> a(n), b(n), c(n);
	for (int i = 0; i < n; i++)
		cin >> a[i];
	ll sm = 0;
	ld lo = 1, hi = 1e9;
	int m = -1;
	for (int i = 1; i + 1 < n; i++) {
		if (a[i - 1] > a[i] && a[i] < a[i + 1]) {
			assert(m == -1);
			m = i;
		}
	}
	assert(m != -1);
	for (int it = 0; it < 70; it++) {
		ld mi = (lo + hi) / 2, pref = 0, mn = 0;
		int ok = 0;
		for (int i = 0; i < m; i++) {
			pref += a[i] - mi;
			mn = min(mn, pref);
		}
		pref += a[m] - mi;
		for (int i = m + 1; !ok && i < n; i++) {
			pref += a[i] - mi;
			if (pref >= mn)
				ok = 1;
		}
		if (ok == 1)
			lo = mi;
		else
			hi = mi;
	}
	cout << fixed << setprecision(10) << lo << "\n";
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	int t; cin >> t; while (t--) solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3916kb

input:

2
4
8 2 7 10
6
9 6 5 3 4 8

output:

6.7500000000
5.8333333333

result:

ok 2 numbers

Test #2:

score: 0
Accepted
time: 152ms
memory: 3840kb

input:

100000
3
948511478 739365502 813471668
3
881046825 27458122 398507422
3
987554257 399092415 924260278
3
984128569 125199021 716360525
3
529589236 45783262 313507287
3
645443456 85994112 226010681
3
914820717 228360911 572267310
3
418958362 56703604 195276041
3
64461646 26764720 26995581
3
914535039 ...

output:

833782882.6666666666
435670789.6666666667
770302316.6666666666
608562705.0000000000
296293261.6666666667
319149416.3333333333
571816312.6666666666
223646002.3333333333
39407315.6666666667
383253737.6666666667
734363638.6666666666
779975824.3333333333
490276408.3333333333
574448414.0000000000
3379802...

result:

ok 100000 numbers

Test #3:

score: -100
Wrong Answer
time: 54ms
memory: 4128kb

input:

10000
4
194123849 79274911 191162487 570110764
86
957917218 915359202 914726017 873273226 867724859 867674150 809652204 805531383 745262007 743835491 727071232 714782071 645394643 639432679 594879540 587173904 583418126 560538589 518721836 469558994 427721766 411582333 404948350 402948978 357228675 ...

output:

280182720.6666666667
538557639.9545454545
495489050.3529411764
537734928.6410256411
472025965.7000000000
546154003.1250000000
543366581.5161290323
254833443.2000000000
447343683.3157894736
502458665.3846153846
564217787.3333333333
479468115.1182795699
469762036.6500000000
598722986.9285714285
537648...

result:

wrong answer 1st numbers differ - expected: '258668002.7500000', found: '280182720.6666667', error = '0.0831750'