Submission #1127007

#TimeUsernameProblemLanguageResultExecution timeMemory
1127007gawr_guraSeesaw (JOI22_seesaw)C++20
1 / 100
62 ms328 KiB
#include <bits/stdc++.h> using namespace std; #define int long long using ii = pair<int, int>; using tp = tuple<int, int, int>; const int N = 2e5 + 5; int n, a[N]; namespace sub1{ int pref[N]; int get(int l, int r){ return pref[r] - pref[l - 1]; } void solve(){ for(int i = 1; i <= n; i++) pref[i] = pref[i - 1] + a[i]; long double res = 1e18; for(int msk = 0; msk < (1 << n - 1); msk++){ int L = 1, R = n; long double mx, mn; mx = mn = (long double)get(L, R) / n; for(int i = 0; i < n - 1; i++){ if(msk >> i & 1) R -= 1; else L += 1; mx = max(mx, (long double)get(L, R) / (R - L + 1)); mn = min(mn, (long double)get(L, R) / (R - L + 1)); } res = min(res, mx - mn); } cout << setprecision(12) << fixed << res << "\n"; } } int32_t main(){ cin.tie(0)->sync_with_stdio(0); #define task "SEESAW" 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]; sub1::solve(); return 0; } /* 3 1 2 4 6 1 2 5 6 8 9 */

Compilation message (stderr)

seesaw.cpp: In function 'int32_t main()':
seesaw.cpp:46:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   46 |     freopen(task ".inp", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
seesaw.cpp:47:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   47 |     freopen(task ".out", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...