QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#378276 | #8242. V-Diagram | PZheng | WA | 159ms | 3892kb | C++14 | 682b | 2024-04-06 10:41:47 | 2024-04-06 10:41:49 |
Judging History
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 = a[cur2 - 1];
}
}
printf("%.9f\n", ans);
}
int main() {
int t;
cin >> t;
while(t--) {
solve();
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3892kb
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: 159ms
memory: 3660kb
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'