# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
163424 | 2019-11-13T09:03:38 Z | iefnah06 | Stove (JOI18_stove) | C++11 | 58 ms | 2420 KB |
#include <bits/stdc++.h> using namespace std; const int MAXN = 3e5; int N, K; int T[MAXN]; int main() { scanf("%d %d", &N, &K); for (int i = 0; i < N; i++) { scanf("%d", &T[i]); } vector<int> gaps; for (int i = 0; i < N - 1; i++) { gaps.push_back(T[i + 1] - T[i] - 1); } nth_element(gaps.begin(), gaps.begin() + K - 1, gaps.end(), greater<int>()); int ans = T[N - 1] - T[0] + 1; for (int i = 0; i < K - 1; i++) { ans -= gaps[i]; } printf("%d\n", ans); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 256 KB | Output is correct |
4 | Correct | 2 ms | 256 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 | 19 ms | 376 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 256 KB | Output is correct |
4 | Correct | 2 ms | 256 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 | 19 ms | 376 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 3 ms | 376 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 | 444 KB | Output is correct |
14 | Correct | 3 ms | 376 KB | Output is correct |
15 | Correct | 7 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 256 KB | Output is correct |
4 | Correct | 2 ms | 256 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 | 19 ms | 376 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 3 ms | 376 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 | 444 KB | Output is correct |
14 | Correct | 3 ms | 376 KB | Output is correct |
15 | Correct | 7 ms | 384 KB | Output is correct |
16 | Correct | 20 ms | 2384 KB | Output is correct |
17 | Correct | 21 ms | 2292 KB | Output is correct |
18 | Correct | 21 ms | 2292 KB | Output is correct |
19 | Correct | 21 ms | 2288 KB | Output is correct |
20 | Correct | 22 ms | 2420 KB | Output is correct |
21 | Correct | 21 ms | 2292 KB | Output is correct |
22 | Correct | 21 ms | 2296 KB | Output is correct |
23 | Correct | 58 ms | 2292 KB | Output is correct |
24 | Correct | 46 ms | 2292 KB | Output is correct |