Submission #1120227

# Submission time Handle Problem Language Result Execution time Memory
1120227 2024-11-28T06:38:29 Z Aisha Stove (JOI18_stove) C++17
20 / 100
1000 ms 72564 KB
#include <bits/stdc++.h>

using namespace std;

#define int long long

int ans = 1e9;

void f(int i, int k, int n, vector <int> a, int sum) {
    if (k < 0) return;
    if (i == n - 1) ans = min(ans, sum);
    if (i == n - 1) return;

    f(i + 1, k, n, a, sum + (a[i + 1] - a[i]));
    f(i + 1, k - 1, n, a, sum + 1);
}

signed main() {
    int n, k;
    cin >> n >> k; 

    vector <int> a(n);
    for (int i = 0; i < n; i ++) cin >> a[i];

    f(0, k-1, n, a, 1);

    cout << ans << endl;

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 596 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 440 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 16 ms 512 KB Output is correct
9 Correct 2 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 596 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 440 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 16 ms 512 KB Output is correct
9 Correct 2 ms 340 KB Output is correct
10 Execution timed out 1075 ms 72564 KB Time limit exceeded
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 596 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 440 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 16 ms 512 KB Output is correct
9 Correct 2 ms 340 KB Output is correct
10 Execution timed out 1075 ms 72564 KB Time limit exceeded
11 Halted 0 ms 0 KB -