QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#627639 | #8242. V-Diagram | taijinvjin# | WA | 0ms | 4032kb | C++17 | 999b | 2024-10-10 16:34:40 | 2024-10-10 16:34:41 |
Judging History
answer
#include <bits/stdc++.h>
void solve() {
int n;
std::cin >> n;
std::vector<int> a(n + 1);
int id = 0;
for (int i = 1; i <= n; i ++) {
std::cin >> a[i];
}
for (int i = 2; i <= n - 1; i ++) {
if (a[i] < a[i - 1] && a[i] < a[i + 1]) id = i, i = n - 1;
}
long double Ans = (a[id] + a[id - 1] + a[id + 1]);
long long L = 0, R = 0;
for (int i = 1; i < id - 1; i ++) L += a[i];
for (int i = id + 2; i <= n; i ++) R += a[i];
if ((R + Ans) / (3 + n - id - 1) > 1.0 * L / (id - 2)) {
std::cout << (R + Ans) / (3 + n - id - 1) << "\n";
}else if ((L + Ans) / (id - 2 + 3) > 1.0 * R / (n - id - 1) ) {
std::cout << (L + Ans) / (id - 2 + 3) << "\n";
}else {
std::cout << (Ans + L + R) / n << "\n";
}
}
signed main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int T = 1;
std::cin >> T;
while (T --) {
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 4032kb
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'