제출 #1123494

#제출 시각아이디문제언어결과실행 시간메모리
1123494pndhpndhStove (JOI18_stove)C++20
0 / 100
1 ms320 KiB
#include<bits/stdc++.h> #define int long long #define pb push_back #define task "task" using namespace std; const int inf = 1e9; const int mx = 2e5 + 5; int n, k; double a[mx]; pair<double,int> dp[mx]; void read(){ cin >> n >> k; for (int i = 1; i <= n; i++){ cin >> a[i]; } } void solve(){ double l = 0, r = inf; double ans; for (int t = 1; t <= 100; t++){ double mid = (l + r)/2; for (int i = 1; i <= n; i++){ dp[i] = {0.0, 0}; } dp[1] = {1.1, 1}; for (int i = 2; i <= n; i++){ dp[i] = min(make_pair(dp[i - 1].first + 1.0 + mid, dp[i - 1].second + 1), make_pair(dp[i - 1].first + a[i] - a[i - 1], dp[i - 1].second)); } if (dp[n].second <= k){ ans = dp[n].first - mid * (dp[n].second - 1); r = mid; }else{ l = mid; } } cout << ans; } signed main(){ cin.tie(0)->sync_with_stdio(0); if(fopen(task".inp", "r")){ freopen(task".inp", "r", stdin); freopen(task".out", "w", stdout); } read(); solve(); }

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

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