QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#378268#8242. V-DiagramPZhengWA 164ms3844kbC++14672b2024-04-06 10:36:132024-04-06 10:36:13

Judging History

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

  • [2024-04-06 10:36:13]
  • 评测
  • 测评结果:WA
  • 用时:164ms
  • 内存:3844kb
  • [2024-04-06 10:36:13]
  • 提交

answer

#include <iostream>
#include <vector>
#include <cstdio>

using namespace std;
using i64 = long long;

void solve() {
	int n;
	cin >> n;
	vector<i64> a(n);
	for(int i = 0; i < n; i++) {
		cin >> a[i];
	}
	double ans = 0;
	int cur1 = 0, cur2 = 1, sums = 0;
	sums += a[0];
	bool flag = (a[1] >= a[0]);
	while(cur2 != n) {
		while(cur2 != n && ((a[cur2] < a[cur2 - 1]) ^ flag)) {
			sums += a[cur2];
			cur2++;
		}
		flag ^= 1;
		if(flag == 0) {
			ans = max(double(sums) / (cur2 - cur1), ans);
			cur1 = cur2 - 1;
			sums = 0;
		}
 	}
 	printf("%.9f\n", ans);
}

int main() {
	int t;
	cin >> t;
	while(t--) {
		solve();
	}
	return 0;
}

详细

Test #1:

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

input:

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

output:

6.750000000
5.833333333

result:

ok 2 numbers

Test #2:

score: -100
Wrong Answer
time: 164ms
memory: 3704kb

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.000000000
435670789.666666687
0.000000000
608562705.000000000
296293261.666666687
319149416.333333313
571816312.666666627
223646002.333333343
39407315.666666664
383253737.666666687
0.000000000
0.000000000
490276408.333333313
574448414.000000000
337980292.000000000
654961203.666666627
583384189.333...

result:

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