제출 #281816

#제출 시각아이디문제언어결과실행 시간메모리
281816BeanZStove (JOI18_stove)C++14
50 / 100
102 ms153080 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define endl '\n' const int N = 1e5 + 5; const int mod = 1e9 + 7; ll a[5005], dp[5005][5005][2]; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); if (fopen("VietCT.INP", "r")){ freopen("VietCT.INP", "r", stdin); freopen("VietCT.OUT", "w", stdout); } ll n, k; cin >> n >> k; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 0; i <= n; i++){ for (int j = 0; j <= k; j++){ for (int x = 0; x < 2; x++){ dp[i][j][x] = 1e10; } } } dp[1][1][0] = 1; dp[1][1][1] = 1; for (int i = 2; i <= n; i++){ for (int j = 1; j <= min(1ll * i, k); j++){ dp[i][j][0] = min(dp[i][j][0], dp[i - 1][j][0] + a[i] - a[i - 1]); dp[i][j][0] = min(dp[i][j][0], dp[i - 1][j - 1][1] + 1); dp[i][j][1] = min(dp[i][j][1], dp[i - 1][j][0] + a[i] - a[i - 1]); dp[i][j][1] = min(dp[i][j][1], dp[i - 1][j - 1][1] + 1); } } ll ans = 1e18; for (int i = 1; i <= k; i++){ ans = min(ans, dp[n][i][1]); } cout << ans; } /* */

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

stove.cpp: In function 'int main()':
stove.cpp:14:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   14 |                 freopen("VietCT.INP", "r", stdin);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
stove.cpp:15:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   15 |                 freopen("VietCT.OUT", "w", stdout);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...