# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
931896 | 2024-02-22T14:16:27 Z | lovrot | Stove (JOI18_stove) | C++17 | 17 ms | 1788 KB |
#include <cstdio> #include <algorithm> #include <cstring> #include <cmath> #include <iostream> #include <set> #include <queue> #include <deque> #include <vector> #include <random> #include <chrono> #define X first #define Y second #define PB push_back #define EB emplace_back using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int MOD = 1e9 + 7; // 998 244 353; const int N = 1e5 + 10; int n, k, A[N]; int main() { scanf("%d%d", &n, &k); int lst = 0, ans = 0; for(int i = 0; i < n; ++i) { int x; scanf("%d", &x); A[i] = x - lst - 1; if(!i) ans -= x; if(i == n - 1) ans += x + 1; lst = x; } sort(A + 1, A + n, [](int a, int b) { return a > b; }); for(int i = 1; i < k; ++i) ans -= A[i]; printf("%d\n", ans); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 1 ms | 344 KB | Output is correct |
11 | Correct | 1 ms | 348 KB | Output is correct |
12 | Correct | 1 ms | 348 KB | Output is correct |
13 | Correct | 1 ms | 484 KB | Output is correct |
14 | Correct | 1 ms | 348 KB | Output is correct |
15 | Correct | 1 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 1 ms | 344 KB | Output is correct |
11 | Correct | 1 ms | 348 KB | Output is correct |
12 | Correct | 1 ms | 348 KB | Output is correct |
13 | Correct | 1 ms | 484 KB | Output is correct |
14 | Correct | 1 ms | 348 KB | Output is correct |
15 | Correct | 1 ms | 348 KB | Output is correct |
16 | Correct | 17 ms | 1628 KB | Output is correct |
17 | Correct | 16 ms | 1788 KB | Output is correct |
18 | Correct | 16 ms | 1676 KB | Output is correct |
19 | Correct | 16 ms | 1628 KB | Output is correct |
20 | Correct | 16 ms | 1628 KB | Output is correct |
21 | Correct | 16 ms | 1584 KB | Output is correct |
22 | Correct | 16 ms | 1624 KB | Output is correct |
23 | Correct | 16 ms | 1688 KB | Output is correct |
24 | Correct | 16 ms | 1700 KB | Output is correct |