Submission #345526

# Submission time Handle Problem Language Result Execution time Memory
345526 2021-01-07T14:31:03 Z pragmatist K blocks (IZhO14_blocks) C++14
0 / 100
1 ms 512 KB
// turmak-_-
#include<bits/stdc++.h>

#define all(v) v.begin(),v.end()
#define sz(a) a.size()
#define nl "\n"
#define IOI return 0;
#define pb push_back
#define ppb pop_back()
#define ll long long
#define ull unsigned long long
#define ld long double
#define IOS ios_base :: sync_with_stdio(NULL); cin.tie(0); cout.tie(0);
#define pii pair<int,int>
#define X first
#define Y second


using namespace std;
const int N = (int)1e5 + 7 ;
const ll MOD = (ll)998244353;
const ll INF = (ll)1e18 + 7;
const int inf = (int)1e9 + 7;

pii dx[] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
int a[N],n,q;
int dp[200][200];
void solve() {
    cin>>n>>q;
    int mx = 0;
    for(int i=1; i<=n; ++i) {
        cin>>a[i];
        mx = max(mx, a[i]);
        dp[i][1]=mx;
    }
    for(int i=2; i<=n; ++i) {
        for(int k=2; k<=q; ++k) {
            int mn = inf, pos;
            for(int j=1; j<i; ++j) {
                if(mn>dp[j][k-1]) {
                    mn = dp[j][k-1];
                    pos = j;
                }
            }
            //printf("%d\n", pos);
            int Mx = 0;
            for(int j=pos+1; j<=i; ++j) {
                Mx = max(Mx, a[j]);
            }
            dp[i][k]=dp[pos][k-1] + Mx;
            //cout<<i<<' '<<pos<<' '<<dp[i][k]<<nl;
        }
        //cout<<nl;
    }

    cout<<dp[n][q];

}
int main() {
    IOS
    //freopen("cinema.in", "r", stdin);
    //freopen("cinema.out", "w", stdout);
    int tt=1;
    //  cin>>tt;
    while(tt--) {
        solve();
    }
    IOI
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 396 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Incorrect 1 ms 364 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Incorrect 1 ms 512 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 396 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Incorrect 1 ms 364 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 396 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Incorrect 1 ms 364 KB Output isn't correct
9 Halted 0 ms 0 KB -