Submission #100537

# Submission time Handle Problem Language Result Execution time Memory
100537 2019-03-12T06:16:31 Z 1Khan K blocks (IZhO14_blocks) C++14
18 / 100
1000 ms 384 KB
/// 1n  the  name  of  GOD

#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <cstdio>

using   namespace        std;

#define ko               exit(0);
#define nl               '\n'
#define ios              ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define sz(s)            (int)s.size()
#define all(s)           s.begin(), s.end()
#define oll(s, n, c)     (s) + (c), s + (n) + c
#define pb               push_back
#define ff               first
#define ss               second
#define pii              pair<int, int>

typedef long long ll;
typedef double db;

const int N = 1e5 + 111;
const int M = 1e9 + 7;

int n, k;
int a[N];
int calc(int v = 1, int cnt = k) {
     if (v > n) {
          if (cnt != 0) return 1e9;
          return 0;
     }
     if (cnt < 0) return 1e9;
     int res = 1e9;
     int mx = 0;
     for (int i = v; i <= n - cnt + 1; i++) {
          mx = max(mx, a[i]);
          res = min(res, calc(i + 1, cnt - 1) + mx);
     }
     return res;
}
int main(){
     cin >> n >> k;
     for (int i = 1; i <= n; i++) {
          cin >> a[i];
     }

     cout << calc();
     return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 3 ms 256 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Execution timed out 1080 ms 256 KB Time limit exceeded
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 3 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 304 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 4 ms 256 KB Output is correct
15 Correct 5 ms 256 KB Output is correct
16 Correct 2 ms 256 KB Output is correct
17 Correct 2 ms 256 KB Output is correct
18 Correct 5 ms 256 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1079 ms 384 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1084 ms 384 KB Time limit exceeded
2 Halted 0 ms 0 KB -