# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
170261 | 2019-12-24T12:18:25 Z | Akashi | Stove (JOI18_stove) | C++14 | 27 ms | 2168 KB |
#include <bits/stdc++.h> using namespace std; int n, k; int a[100005], b[100005]; int main() { scanf("%d%d", &n, &k); --k; int Sum = 0, Max = 0, Min = 2e9; for(int i = 1; i <= n ; ++i){ scanf("%d", &a[i]); if(i > 1) b[i] = a[i] - a[i - 1] - 1; Max = max(Max, a[i]); Min = min(Min, a[i]); } Sum = Max - Min + 1; sort(b + 1, b + n + 1); for(int i = n; i > n - k ; --i) Sum -= b[i]; printf("%d", Sum); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 256 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 256 KB | Output is correct |
7 | Correct | 2 ms | 256 KB | Output is correct |
8 | Correct | 2 ms | 248 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 256 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 256 KB | Output is correct |
7 | Correct | 2 ms | 256 KB | Output is correct |
8 | Correct | 2 ms | 248 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 3 ms | 540 KB | Output is correct |
11 | Correct | 3 ms | 376 KB | Output is correct |
12 | Correct | 3 ms | 376 KB | Output is correct |
13 | Correct | 3 ms | 376 KB | Output is correct |
14 | Correct | 3 ms | 376 KB | Output is correct |
15 | Correct | 3 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 256 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 256 KB | Output is correct |
7 | Correct | 2 ms | 256 KB | Output is correct |
8 | Correct | 2 ms | 248 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 3 ms | 540 KB | Output is correct |
11 | Correct | 3 ms | 376 KB | Output is correct |
12 | Correct | 3 ms | 376 KB | Output is correct |
13 | Correct | 3 ms | 376 KB | Output is correct |
14 | Correct | 3 ms | 376 KB | Output is correct |
15 | Correct | 3 ms | 376 KB | Output is correct |
16 | Correct | 27 ms | 2168 KB | Output is correct |
17 | Correct | 27 ms | 2100 KB | Output is correct |
18 | Correct | 27 ms | 2040 KB | Output is correct |
19 | Correct | 27 ms | 2040 KB | Output is correct |
20 | Correct | 27 ms | 2040 KB | Output is correct |
21 | Correct | 27 ms | 2040 KB | Output is correct |
22 | Correct | 27 ms | 2040 KB | Output is correct |
23 | Correct | 27 ms | 2040 KB | Output is correct |
24 | Correct | 27 ms | 2040 KB | Output is correct |