# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
802096 |
2023-08-02T09:51:52 Z |
NothingXD |
Seesaw (JOI22_seesaw) |
C++17 |
|
43 ms |
340 KB |
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef double ld;
void debug_out(){cerr<<endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T){
cerr << H << ' ';
debug_out(T...);
}
#define debug(...) cerr << "(" << #__VA_ARGS__ << "): ", debug_out(__VA_ARGS__)
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define MP(x, y) make_pair(x, y)
const int maxn = 100 + 10;
int n, a[maxn];
vector<ld> L;
bool check(ld L, ld R){
//debug(L, R);
ld sum = 0;
for (int i = 1; i <= n; i++){
sum += a[i];
}
int l = 1, r = n;
ld tmp = sum / n;
//debug(tmp);
if (tmp < L || R < tmp) return false;
for (int i = 1; i < n; i++){
ld tmp1 = (sum - a[l]) / (n-i);
ld tmp2 = (sum - a[r]) / (n-i);
// debug(l, r, tmp1, tmp2);
if (L <= tmp1 && tmp1 <= R){
sum -= a[l];
l++;
}
else if (L <= tmp2 && tmp2 <= R){
sum -= a[r];
r--;
}
else return false;
}
return true;
}
bool check(ld x){
for (auto y: L){
if (check(y, y+x)) return true;
}
return false;
}
int main(){
cin >> n;
for (int i = 1; i <= n; i++){
cin >> a[i];
}
for (int i = 1; i <= n; i++){
for (int j = i; j <= n; j++){
ld tmp = 0;
for (int k = i; k <= j; k++){
tmp += a[k];
}
tmp /= (j-i+1);
//debug(i, j, tmp);
L.push_back(tmp);
}
}
ld l = 0, r = 1e9;
for (int i = 1; i <= 100; i++){
ld mid = (l + r) / 2;
// debug(l, r, mid);
if (check(mid)) r = mid;
else l = mid;
}
cout << setprecision(12) << r << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
304 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
304 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
39 ms |
340 KB |
Output is correct |
5 |
Correct |
43 ms |
340 KB |
Output is correct |
6 |
Correct |
36 ms |
340 KB |
Output is correct |
7 |
Correct |
34 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
304 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
39 ms |
340 KB |
Output is correct |
5 |
Correct |
43 ms |
340 KB |
Output is correct |
6 |
Correct |
36 ms |
340 KB |
Output is correct |
7 |
Correct |
34 ms |
340 KB |
Output is correct |
8 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
304 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
39 ms |
340 KB |
Output is correct |
5 |
Correct |
43 ms |
340 KB |
Output is correct |
6 |
Correct |
36 ms |
340 KB |
Output is correct |
7 |
Correct |
34 ms |
340 KB |
Output is correct |
8 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
9 |
Halted |
0 ms |
0 KB |
- |