# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
41099 | 2018-02-12T17:01:21 Z | bugmenot111 | Stove (JOI18_stove) | C++14 | 30 ms | 1288 KB |
#include <cstdio> #include <algorithm> #define MAXN 100100 int diff[MAXN], a[MAXN]; int main(void) { int n, k; scanf("%d%d", &n, &k); for(int i = 0; i < n; i++) scanf("%d", &a[i]); int ans = a[n - 1] - a[0] + 1; for(int i = 1; i < n; i++) diff[i] = a[i] - a[i - 1]; std::sort(diff + 1, diff + n, std::greater<int>()); for(int i = 1; i < k; i++) ans -= diff[i] - 1; printf("%d\n", ans); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 248 KB | Output is correct |
2 | Correct | 1 ms | 352 KB | Output is correct |
3 | Correct | 1 ms | 352 KB | Output is correct |
4 | Correct | 1 ms | 568 KB | Output is correct |
5 | Correct | 1 ms | 568 KB | Output is correct |
6 | Correct | 2 ms | 568 KB | Output is correct |
7 | Correct | 1 ms | 568 KB | Output is correct |
8 | Correct | 1 ms | 568 KB | Output is correct |
9 | Correct | 2 ms | 568 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 248 KB | Output is correct |
2 | Correct | 1 ms | 352 KB | Output is correct |
3 | Correct | 1 ms | 352 KB | Output is correct |
4 | Correct | 1 ms | 568 KB | Output is correct |
5 | Correct | 1 ms | 568 KB | Output is correct |
6 | Correct | 2 ms | 568 KB | Output is correct |
7 | Correct | 1 ms | 568 KB | Output is correct |
8 | Correct | 1 ms | 568 KB | Output is correct |
9 | Correct | 2 ms | 568 KB | Output is correct |
10 | Correct | 2 ms | 576 KB | Output is correct |
11 | Correct | 2 ms | 620 KB | Output is correct |
12 | Correct | 2 ms | 620 KB | Output is correct |
13 | Correct | 2 ms | 620 KB | Output is correct |
14 | Correct | 3 ms | 620 KB | Output is correct |
15 | Correct | 2 ms | 620 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 248 KB | Output is correct |
2 | Correct | 1 ms | 352 KB | Output is correct |
3 | Correct | 1 ms | 352 KB | Output is correct |
4 | Correct | 1 ms | 568 KB | Output is correct |
5 | Correct | 1 ms | 568 KB | Output is correct |
6 | Correct | 2 ms | 568 KB | Output is correct |
7 | Correct | 1 ms | 568 KB | Output is correct |
8 | Correct | 1 ms | 568 KB | Output is correct |
9 | Correct | 2 ms | 568 KB | Output is correct |
10 | Correct | 2 ms | 576 KB | Output is correct |
11 | Correct | 2 ms | 620 KB | Output is correct |
12 | Correct | 2 ms | 620 KB | Output is correct |
13 | Correct | 2 ms | 620 KB | Output is correct |
14 | Correct | 3 ms | 620 KB | Output is correct |
15 | Correct | 2 ms | 620 KB | Output is correct |
16 | Correct | 26 ms | 1288 KB | Output is correct |
17 | Correct | 26 ms | 1288 KB | Output is correct |
18 | Correct | 30 ms | 1288 KB | Output is correct |
19 | Correct | 27 ms | 1288 KB | Output is correct |
20 | Correct | 25 ms | 1288 KB | Output is correct |
21 | Correct | 26 ms | 1288 KB | Output is correct |
22 | Correct | 27 ms | 1288 KB | Output is correct |
23 | Correct | 27 ms | 1288 KB | Output is correct |
24 | Correct | 25 ms | 1288 KB | Output is correct |