# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
62224 | 2018-07-27T22:20:58 Z | kingpig9 | Stove (JOI18_stove) | C++11 | 57 ms | 10620 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; const int MAXN = 1e5 + 10; #define debug(...) fprintf(stderr, __VA_ARGS__) #define fi first #define se second #define all(v) (v).begin(), (v).end() #define fillchar(a, s) memset((a), (s), sizeof(a)) int N, K; int A[MAXN]; int main() { scanf("%d %d", &N, &K); for (int i = 0; i < N; i++) { scanf("%d", &A[i]); } sort(A, A + N); int ans = A[N - 1] - A[0] + 1; priority_queue<int> pq; for (int i = 0; i < N; i++) { pq.push(A[i + 1] - A[i] - 1); } //K - 1 times at most for (int i = 1; i < K; i++) { if (pq.empty()) { break; } ans -= pq.top(); pq.pop(); } printf("%d\n", ans); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 248 KB | Output is correct |
2 | Correct | 4 ms | 360 KB | Output is correct |
3 | Correct | 3 ms | 448 KB | Output is correct |
4 | Correct | 3 ms | 448 KB | Output is correct |
5 | Correct | 3 ms | 448 KB | Output is correct |
6 | Correct | 3 ms | 480 KB | Output is correct |
7 | Correct | 2 ms | 636 KB | Output is correct |
8 | Correct | 2 ms | 636 KB | Output is correct |
9 | Correct | 3 ms | 636 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 248 KB | Output is correct |
2 | Correct | 4 ms | 360 KB | Output is correct |
3 | Correct | 3 ms | 448 KB | Output is correct |
4 | Correct | 3 ms | 448 KB | Output is correct |
5 | Correct | 3 ms | 448 KB | Output is correct |
6 | Correct | 3 ms | 480 KB | Output is correct |
7 | Correct | 2 ms | 636 KB | Output is correct |
8 | Correct | 2 ms | 636 KB | Output is correct |
9 | Correct | 3 ms | 636 KB | Output is correct |
10 | Correct | 4 ms | 636 KB | Output is correct |
11 | Correct | 4 ms | 636 KB | Output is correct |
12 | Correct | 3 ms | 672 KB | Output is correct |
13 | Correct | 4 ms | 704 KB | Output is correct |
14 | Correct | 4 ms | 736 KB | Output is correct |
15 | Correct | 6 ms | 768 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 248 KB | Output is correct |
2 | Correct | 4 ms | 360 KB | Output is correct |
3 | Correct | 3 ms | 448 KB | Output is correct |
4 | Correct | 3 ms | 448 KB | Output is correct |
5 | Correct | 3 ms | 448 KB | Output is correct |
6 | Correct | 3 ms | 480 KB | Output is correct |
7 | Correct | 2 ms | 636 KB | Output is correct |
8 | Correct | 2 ms | 636 KB | Output is correct |
9 | Correct | 3 ms | 636 KB | Output is correct |
10 | Correct | 4 ms | 636 KB | Output is correct |
11 | Correct | 4 ms | 636 KB | Output is correct |
12 | Correct | 3 ms | 672 KB | Output is correct |
13 | Correct | 4 ms | 704 KB | Output is correct |
14 | Correct | 4 ms | 736 KB | Output is correct |
15 | Correct | 6 ms | 768 KB | Output is correct |
16 | Correct | 30 ms | 2764 KB | Output is correct |
17 | Correct | 32 ms | 3728 KB | Output is correct |
18 | Correct | 26 ms | 4688 KB | Output is correct |
19 | Correct | 31 ms | 5656 KB | Output is correct |
20 | Correct | 34 ms | 6620 KB | Output is correct |
21 | Correct | 41 ms | 7600 KB | Output is correct |
22 | Correct | 57 ms | 8692 KB | Output is correct |
23 | Correct | 53 ms | 9528 KB | Output is correct |
24 | Correct | 41 ms | 10620 KB | Output is correct |