# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1127009 | gawr_gura | Seesaw (JOI22_seesaw) | C++20 | 2094 ms | 328 KiB |
#include<bits/stdc++.h>
#define fori(i,a,b) for(int i=a;i<=b;i++)
#define int long long
#define pb push_back
using namespace std;
typedef pair<int,int> ii;
typedef tuple<int,int,int> tp;
const int M = 1e6 + 10;
const int N = 1e3 + 10;
const int mod = 1e9 + 7;
const double base = 1.000000000;
int n, a[M];
double kq = 1e15;
int x[M];
void ktra()
{
double sum = 0;
for(int i = 1;i <= n; i++) sum += a[i];
int l = 1, r = n;
double u = sum/n, v = sum/n;
for(int i = 1;i <= n - 1; i++) {
if(x[i] == 0) {
sum -= a[l];
l++;
double val = base * sum/(n - i);
//cout << sum << " " << (n - i) << " " << val << "\n";
u = min(u, val);
v = max(v, val);
}
else {
sum -= a[r];
r--;
double val = base * sum/(n - i);
//cout << sum << " " << (n - i) << " " << val << "\n" ;
u = min(u, val);
v = max(v, val);
}
}
//cout << u << " " << v << "\n";
//cout << endl;
kq = min(kq, base * v - u);
}
void duyet(int i)
{
if(i == n) ktra();
else
{
for(int j = 0;j <= 1; j++) {
x[i] = j;
duyet(i + 1);
}
}
}
int32_t main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
if(fopen("1.inp","r")) {
freopen("1.inp","r",stdin);
freopen("1.out","w",stdout);
}
#define task ""
if(fopen(task".inp","r")) {
freopen(task".inp","r",stdin);
freopen(task".out","w",stdout);
}
cin >> n ;
for(int i = 1;i <= n; i++) cin >> a[i];
duyet(1);
cout << fixed << setprecision(9) << kq ;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |