제출 #1162345

#제출 시각아이디문제언어결과실행 시간메모리
1162345blackslexK blocks (IZhO14_blocks)C++20
0 / 100
0 ms528 KiB
#include<bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<ll, ll>; int n, k; int main() { scanf("%d %d", &n, &k); vector<int> a(n + 5); vector<vector<ll>> dp(2, vector<ll>(n + 5)); for (int i = 1; i <= n; i++) scanf("%d", &a[i]); for (int i = 1; i <= k; i++) { for (int j = 1; j <= n; j++) dp[i & 1][j] = 1e18; stack<pii> st; for (int j = i; j <= n; j++) { ll cmn = dp[!(j & 1)][i - 1]; while (!st.empty() && a[st.top().first] <= a[j]) { cmn = min(cmn, st.top().second); st.pop(); } dp[i & 1][j] = cmn + a[j]; if (!st.empty()) dp[j & 1][i] = min(dp[i & 1][j], st.top().second); st.emplace(j, cmn); } for (int j = 0; j < i; j++) dp[i & 1][j] = 1e18; } printf("%lld", dp[k & 1][n]); }

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

blocks.cpp: In function 'int main()':
blocks.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     scanf("%d %d", &n, &k);
      |     ~~~~~^~~~~~~~~~~~~~~~~
blocks.cpp:13:39: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
      |                                  ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...