Submission #1127006

#TimeUsernameProblemLanguageResultExecution timeMemory
1127006gawr_guraSeesaw (JOI22_seesaw)C++20
1 / 100
69 ms328 KiB
#include <bits/stdc++.h> #define ll long long using namespace std; const int N = 1e6 + 5; int n; double a[N]; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(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]; double ans = (double)(2e9); for(int msk = 0; msk < (1 << n); msk ++) { double sum = 0; int l = 1, r = n; for(int i = 1; i <= n; i ++) sum += a[i]; double cnt = n; double mi = (1.0 * sum) / (1.0 * cnt); double mx = (1.0 * sum) / (1.0 * cnt); for(int k = 1; k < n; k ++) if(msk >> (k - 1) & 1) { sum -= a[r]; cnt--; mx = max(mx, (1.0 * sum) / (1.0 * cnt)); mi = min(mi, (1.0 * sum) / (1.0 * cnt)); r --; } else { sum -= a[l]; cnt--; mx = max(mx, (1.0 * sum) / (1.0 * cnt)); mi = min(mi, (1.0 * sum) / (1.0 * cnt)); l ++; } ans = min(ans, mx - mi); } cout << setprecision(9) << fixed << ans; }

Compilation message (stderr)

seesaw.cpp: In function 'int main()':
seesaw.cpp:15:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |     freopen(task ".inp","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
seesaw.cpp:16:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |     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...