QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#678413#8242. V-Diagramsenak#WA 81ms3804kbC++201.4kb2024-10-26 14:51:532024-10-26 14:51:54

Judging History

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

  • [2024-10-26 14:51:54]
  • 评测
  • 测评结果:WA
  • 用时:81ms
  • 内存:3804kb
  • [2024-10-26 14:51:53]
  • 提交

answer

// Problem: E. Sakurako, Kosuke, and the Permutation
// Contest: Codeforces - Codeforces Round 981 (Div. 3)
// URL: https://codeforces.com/contest/2033/problem/E
// Memory Limit: 256 MB
// Time Limit: 2000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

#include<iostream>
#include<vector>
#include<map>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include <iomanip>
#include<numeric>
#define int long long
using namespace std;
const int N = 3e5 + 7;
int a[N];
void solve() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	int idx = 0;
	for (int i = 1; i <= n; i++) {
		if (a[i] < a[i - 1] && a[i] < a[i + 1]) {
			idx = i;
			break;
		}
	}
	int l = idx - 1;
	int r = idx + 1;
	int sum = a[idx] + a[l] + a[r];
	int cnt = 3;
	double maxx = 0;
	while (l > 1 || r < n) {
		double maxx2 = 0;
		if (l > 1)maxx2 = max(1.0000 * (sum + a[l - 1]) / (cnt + 1), maxx2);
		if (r < n)maxx2 = max(1.0000 * (sum + a[r + 1]) / (cnt + 1), maxx2);

		if(l > 1 && r < n)
			maxx2 = max(1.0000 * (sum + a[l - 1] + a[r + 1]) / (cnt + 2), maxx2);

		if (l > 1)l--, cnt++, sum += a[l];
		if (r < n)r++, cnt++, sum += a[r];
		maxx = max(maxx, maxx2);
	}
	cout << fixed << setprecision(10) << maxx << endl;
}
signed main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int t; cin >> t; while (t--) solve();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: -100
Wrong Answer
time: 81ms
memory: 3804kb

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:

0.0000000000
0.0000000000
0.0000000000
0.0000000000
0.0000000000
0.0000000000
0.0000000000
0.0000000000
0.0000000000
0.0000000000
0.0000000000
0.0000000000
0.0000000000
0.0000000000
0.0000000000
0.0000000000
0.0000000000
0.0000000000
0.0000000000
0.0000000000
0.0000000000
0.0000000000
0.0000000000
0...

result:

wrong answer 1st numbers differ - expected: '833782882.6666666', found: '0.0000000', error = '1.0000000'