Submission #37925

# Submission time Handle Problem Language Result Execution time Memory
37925 2017-12-29T04:05:00 Z Just_Solve_The_Problem K blocks (IZhO14_blocks) C++11
18 / 100
1000 ms 5140 KB
#include <bits/stdc++.h>

using namespace std;

#define ll long long

const int N = (int)1e5 + 7;

int a[N];
ll ans = 1e14;
int n, k;
vector < int > dns;

void go (int pos, int mx, ll sum = 0, int kk = 1, vector < int > vec = vector < int > ()) {
    mx = max(mx, a[pos]);
    if (pos == n + 1) {
        if (kk == k) {
            if (ans > sum + mx) {
                ans = sum + mx;
                dns = vec;
            }
        }
        return ;
    }
    if (kk + 1 <= k && pos != n) {
        vec.push_back(pos);
        go(pos + 1, 0, sum + mx, kk + 1, vec);
        vec.pop_back();
    }
    go(pos + 1, mx, sum, kk, vec);
}

main() {
    scanf ("%d %d", &n, &k);
    for (int i = 1; i <= n; i++) {
        scanf ("%d", a + i);
    }
    go(1, 0);
    cout << ans << endl;
//    for (int to : dns) {
//        cout << to << ' ' ;
//    }
}

Compilation message

blocks.cpp:33:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() {
      ^
blocks.cpp: In function 'int main()':
blocks.cpp:34:28: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf ("%d %d", &n, &k);
                            ^
blocks.cpp:36:28: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf ("%d", a + i);
                            ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2404 KB Output is correct
2 Correct 0 ms 2404 KB Output is correct
3 Correct 0 ms 2404 KB Output is correct
4 Correct 0 ms 2404 KB Output is correct
5 Correct 0 ms 2404 KB Output is correct
6 Correct 0 ms 2404 KB Output is correct
7 Correct 0 ms 2404 KB Output is correct
8 Correct 0 ms 2404 KB Output is correct
9 Correct 0 ms 2404 KB Output is correct
10 Correct 0 ms 2404 KB Output is correct
11 Correct 0 ms 2404 KB Output is correct
12 Correct 0 ms 2404 KB Output is correct
13 Execution timed out 1000 ms 2404 KB Execution timed out
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2404 KB Output is correct
2 Correct 0 ms 2404 KB Output is correct
3 Correct 0 ms 2404 KB Output is correct
4 Correct 0 ms 2404 KB Output is correct
5 Correct 0 ms 2404 KB Output is correct
6 Correct 0 ms 2404 KB Output is correct
7 Correct 0 ms 2404 KB Output is correct
8 Correct 0 ms 2404 KB Output is correct
9 Correct 0 ms 2404 KB Output is correct
10 Correct 0 ms 2404 KB Output is correct
11 Correct 0 ms 2404 KB Output is correct
12 Correct 0 ms 2404 KB Output is correct
13 Correct 0 ms 2404 KB Output is correct
14 Correct 73 ms 2404 KB Output is correct
15 Correct 59 ms 2404 KB Output is correct
16 Correct 109 ms 2404 KB Output is correct
17 Correct 113 ms 2404 KB Output is correct
18 Correct 63 ms 2404 KB Output is correct
19 Correct 149 ms 2404 KB Output is correct
20 Correct 123 ms 2404 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1000 ms 2404 KB Execution timed out
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1000 ms 5140 KB Execution timed out
2 Halted 0 ms 0 KB -