Submission #861231

#TimeUsernameProblemLanguageResultExecution timeMemory
861231thanhnhanqn77K blocks (IZhO14_blocks)C++14
53 / 100
2 ms2396 KiB
#include <bits/stdc++.h> #define fu(i, a, b) for(int i = (a); i <= (b); i++) #define fd(i, a, b) for(int i = (a); i >= (b); i--) #define ll long long #define pii pair<int, int> #define mp(x, y) make_pair(x, y) #define bit(mask, x) ((mask >> x) & 1) using namespace std; const int N = (int)2e5 + 5; const int LOG = 19; const ll INF = (ll)1e18 + 5; const int MOD = 111539786; int n, lim; int a[N]; ll f[105][105]; void read() { cin >> n >> lim; fu(i, 1, n) cin >> a[i]; int mx = 0; fu(i, 0, n) fu(j, 0, lim) f[i][j] = INF; f[0][0] = 0; fu(i, 1, n) { mx = max(mx, a[i]); int amax = 0; f[i][1] = mx; fd(j, i, 1) { amax = max(amax, a[j]); fu(k, 1, min(i, lim)) { if(f[j - 1][k - 1] != INF) f[i][k] = min(f[i][k], f[j - 1][k - 1] + amax); } } } cout << f[n][lim]; } int main() { // freopen("thaydongA.inp","r",stdin); // freopen("thaydongA.out","w",stdout); ios_base::sync_with_stdio(false); cin.tie(0); read(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...