제출 #1168446

#제출 시각아이디문제언어결과실행 시간메모리
1168446SmuggingSpunK blocks (IZhO14_blocks)C++20
53 / 100
1 ms400 KiB
#include<bits/stdc++.h> #define taskname "B" using namespace std; const int INF = 1e9; const int lim = 1e5 + 5; template<class T>void minimize(T& a, T b){ if(a > b){ a = b; } } template<class T>void maximize(T& a, T b){ if(a < b){ a = b; } } int n, k, a[lim]; namespace sub123{ void solve(){ vector<int>dp(n + 1, INF); for(int _ = dp[0] = 0; _ < k; _++){ vector<int>ndp(n + 1, INF); for(int i = 1; i <= n; i++){ int cur_max = 0; for(int j = i; j > 0; j--){ maximize(cur_max, a[j]); minimize(ndp[i], dp[j - 1] + cur_max); } } swap(dp, ndp); } cout << dp[n]; } } namespace sub4{ void solve(){ } } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if(fopen(taskname".inp", "r")){ freopen(taskname".inp", "r", stdin); } cin >> n >> k; for(int i = 1; i <= n; i++){ cin >> a[i]; } if(n <= 100){ sub123::solve(); } else{ sub4::solve(); } }

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

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