# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
770721 | 2023-07-01T19:41:32 Z | kirakaminski968 | Stove (JOI18_stove) | C++17 | 36 ms | 2336 KB |
#include <bits/stdc++.h> using namespace std; int main() { int N,K; cin >> N >> K; vector<int> arr(N+1),dif; for(int i = 1;i<=N;++i) cin >> arr[i]; if(N == 1){ cout << 1 << "\n"; return 0; } for(int i = 2;i<=N;++i){ if(arr[i]-arr[i-1]-1 != 0) dif.push_back(arr[i]-arr[i-1]-1); } sort(dif.rbegin(),dif.rend()); int ans = arr[N]-arr[1]+1; for(int i = 0;i<K-1;++i){ if(i == dif.size()) break; ans -= dif[i]; } cout << ans << "\n"; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 304 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 296 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 304 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 296 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 340 KB | Output is correct |
11 | Correct | 1 ms | 340 KB | Output is correct |
12 | Correct | 2 ms | 340 KB | Output is correct |
13 | Correct | 2 ms | 312 KB | Output is correct |
14 | Correct | 1 ms | 336 KB | Output is correct |
15 | Correct | 1 ms | 312 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 304 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 296 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 340 KB | Output is correct |
11 | Correct | 1 ms | 340 KB | Output is correct |
12 | Correct | 2 ms | 340 KB | Output is correct |
13 | Correct | 2 ms | 312 KB | Output is correct |
14 | Correct | 1 ms | 336 KB | Output is correct |
15 | Correct | 1 ms | 312 KB | Output is correct |
16 | Correct | 34 ms | 2284 KB | Output is correct |
17 | Correct | 34 ms | 2220 KB | Output is correct |
18 | Correct | 35 ms | 2212 KB | Output is correct |
19 | Correct | 34 ms | 2208 KB | Output is correct |
20 | Correct | 36 ms | 2336 KB | Output is correct |
21 | Correct | 34 ms | 2220 KB | Output is correct |
22 | Correct | 34 ms | 2212 KB | Output is correct |
23 | Correct | 34 ms | 2248 KB | Output is correct |
24 | Correct | 34 ms | 2208 KB | Output is correct |