QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#744278 | #8242. V-Diagram | HaijieTan# | WA | 66ms | 3876kb | C++23 | 2.0kb | 2024-11-13 21:25:08 | 2024-11-13 21:25:11 |
Judging History
answer
#include<iostream>
#include<vector>
#include<bitset>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
#include<numeric>//iota -- iota(all(a), x) a从头到尾从x开始递增
#include<cstring>
#include<ctime>
#include<array>
#include<list>
#include<random>
#include<tuple>
#include<deque>
#include<map>
#include<stack>
#include<set>
using namespace std;
#define IOS ios::sync_with_stdio(false);cin.tie(0), cout.tie(0)
#define int long long
#define all(x) x.begin(), x.end()
#define pb push_back
#define pf push_front
#define lowbit(x) (x & (-x))
const int xy[][2] = { 0,1, 0, -1, 1, 0, -1, 0 };
#define mem(a, x) memset(a, x, sizeof a)
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
typedef pair<char, char> PCC;
typedef pair<int, char> PIC;
typedef pair<char, int> PCI;
#define x first
#define y second
#define NO cout << "NO\n"
#define YES cout << "YES\n"
inline int read();
const int INF = 1e9, N = 1e4 + 10, MOD = 998244353, M = 1e4 + 10, K = 131;
const double PI = acos(-1.0);
void solve() {
int n; cin >> n;
vector<int>a(n + 2), pre(n + 2, 0);
for (int i = 1; i <= n; i++)cin >> a[i], pre[i] = pre[i - 1] + a[i];
int u = 0;
for(int i = 2; i < n; i++)
if (a[i] < a[i - 1] && a[i] < a[i + 1]) {
u = i;
break;
}
int l = 1, r = n;
while (r - l + 1 > 3) {
while (a[r] < r - l + 1 && r > u + 1)r--;
while (a[l] < r - l + 1 && l < u - 1)l++;
if ((a[r] >= r - l + 1 && a[l] >= r - l + 1) || r - l + 1 == 3)break;
}
printf("%.11lf\n", 1.0 * (pre[r] - pre[l - 1]) / (r - l + 1));
}
signed main() {
IOS;
int _ = 1;
cin >> _;
while (_--)solve();
return 0;
}
inline int read()
{
int x = 0, f = 1; char ch = getchar();
while (ch < '0' || ch>'9') { if (ch == '-') f = -1; ch = getchar(); }
while (ch >= '0' && ch <= '9') { x = x * 10 + ch - 48; ch = getchar(); }
return x * f;
}
/* /\_/\
* (= ._.)
* / > \>
*/
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3872kb
input:
2 4 8 2 7 10 6 9 6 5 3 4 8
output:
6.75000000000 5.83333333333
result:
ok 2 numbers
Test #2:
score: 0
Accepted
time: 66ms
memory: 3876kb
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:
833782882.66666662693 435670789.66666668653 770302316.66666662693 608562705.00000000000 296293261.66666668653 319149416.33333331347 571816312.66666662693 223646002.33333334327 39407315.66666666418 383253737.66666668653 734363638.66666662693 779975824.33333337307 490276408.33333331347 574448414.00000...
result:
ok 100000 numbers
Test #3:
score: -100
Wrong Answer
time: 20ms
memory: 3800kb
input:
10000 4 194123849 79274911 191162487 570110764 86 957917218 915359202 914726017 873273226 867724859 867674150 809652204 805531383 745262007 743835491 727071232 714782071 645394643 639432679 594879540 587173904 583418126 560538589 518721836 469558994 427721766 411582333 404948350 402948978 357228675 ...
output:
258668002.75000000000 499947495.38372093439 495489050.35294115543 511519421.86301368475 472025965.69999998808 543693608.25000000000 543366581.51612901688 254833443.19999998808 395528440.97435897589 502458665.38461536169 564217787.33333337307 479468115.11827957630 466246020.20454543829 551500780.7727...
result:
wrong answer 2nd numbers differ - expected: '527118856.7555556', found: '499947495.3837209', error = '0.0515469'