Submission #1248226

#TimeUsernameProblemLanguageResultExecution timeMemory
1248226votranngocvyK blocks (IZhO14_blocks)C11
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define int long long const int N = 2e5 + 5; const int inf = 1e18; int a[N],dp_before[N],dp_cur[N],curMin[N]; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n,k; cin >> n >> k; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 0; i <= n; i++) dp_before[i] = dp_cur[i] = curMin[i] = inf; dp_before[0] = 0; for (int i = 1; i <= k; i++) { stack<int>s; for (int j = i; j <= n; j++) { curMin[j] = dp_before[j - 1]; while (!s.empty() && a[s.top()] <= a[j]) { curMin[j] = min(curMin[j],curMin[s.top()]); s.pop(); } if (s.empty()) dp_cur[j] = curMin[j] + a[j]; else dp_cur[j] = min(dp_cur[s.top()],curMin[j] + a[j]); s.push(j); } for (int j = 0; j <= n; j++) { dp_before[j] = dp_cur[j]; dp_cur[j] = curMin[j] = inf; } } cout << dp_before[n] << "\n"; }

Compilation message (stderr)

blocks.c:1:10: fatal error: bits/stdc++.h: No such file or directory
    1 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.