제출 #1128277

#제출 시각아이디문제언어결과실행 시간메모리
1128277ntdaccodeSeesaw (JOI22_seesaw)C++20
67 / 100
314 ms118256 KiB
#include<bits/stdc++.h> #define fori(i,a,b) for(int i=a;i<=b;i++) #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 = 5e3 + 10; const int mod = 1e9 + 7; int n, a[N], R[N]; double f[N][N]; 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]; double sum = 0; multiset<pair<double,int> > s; for(int i = 1;i <= n; i++) { for(int j = i;j != 0; j--) { sum += a[j]; f[j][i] = sum/(i - j + 1); } double val = sum / i; s.insert({val, i}); R[i] = i; sum = 0; } double kq = 1e15; while(true) { double lval, rval; int len; tie(lval, len) = *s.begin(); rval = prev(s.end()) -> first; s.erase(s.begin()); kq = min(kq, rval - lval); R[len]++; if(R[len] == n + 1) break; else s.insert({f[R[len] - len + 1][R[len]], len}); } cout << fixed << setprecision(12) << kq; }

컴파일 시 표준 에러 (stderr) 메시지

seesaw.cpp: In function 'int32_t main()':
seesaw.cpp:24:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |     freopen("1.inp","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~
seesaw.cpp:25:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |     freopen("1.out","w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~
seesaw.cpp:30:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |     freopen(task".inp","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
seesaw.cpp:31:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |     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...