QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#378266 | #8242. V-Diagram | PZheng | WA | 1ms | 3748kb | C++14 | 651b | 2024-04-06 10:35:10 | 2024-04-06 10:35:10 |
Judging History
answer
#include <iostream>
#include <vector>
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;
}
}
cout << ans << endl;
}
int main() {
int t;
cin >> t;
while(t--) {
solve();
}
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3748kb
input:
2 4 8 2 7 10 6 9 6 5 3 4 8
output:
6.75 5.83333
result:
wrong answer 2nd numbers differ - expected: '5.8333333', found: '5.8333300', error = '0.0000006'