# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
127211 | 2019-07-09T06:45:28 Z | nhimnam120 | Stove (JOI18_stove) | C++14 | 88 ms | 2812 KB |
#include<bits/stdc++.h> using namespace std; vector<long long> inp; vector<long long> pro; signed main(){ long long n,k; cin >> n >> k; for(int i=1;i<=n;i++){ long long a; cin >> a; inp.push_back(a); } long long diff=1; sort(inp.begin(),inp.end()); for(int i=0;i<inp.size()-1;i++){ if(inp[i+1]-inp[i]>1){ diff++; pro.push_back(inp[i+1]-inp[i]-1); } } long long match=diff-k; sort(pro.begin(),pro.end()); if(match<=0){ cout << n; return 0; } long long ans=n; for(int i=0;i<match;i++){ ans+=pro[i]; } cout << ans; }
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 | 376 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 | 252 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 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 | 376 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 | 252 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 4 ms | 376 KB | Output is correct |
11 | Correct | 4 ms | 376 KB | Output is correct |
12 | Correct | 4 ms | 376 KB | Output is correct |
13 | Correct | 4 ms | 376 KB | Output is correct |
14 | Correct | 4 ms | 376 KB | Output is correct |
15 | Correct | 4 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 | 376 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 | 252 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 4 ms | 376 KB | Output is correct |
11 | Correct | 4 ms | 376 KB | Output is correct |
12 | Correct | 4 ms | 376 KB | Output is correct |
13 | Correct | 4 ms | 376 KB | Output is correct |
14 | Correct | 4 ms | 376 KB | Output is correct |
15 | Correct | 4 ms | 376 KB | Output is correct |
16 | Correct | 87 ms | 2660 KB | Output is correct |
17 | Correct | 87 ms | 2812 KB | Output is correct |
18 | Correct | 87 ms | 2588 KB | Output is correct |
19 | Correct | 86 ms | 2584 KB | Output is correct |
20 | Correct | 86 ms | 2668 KB | Output is correct |
21 | Correct | 88 ms | 2668 KB | Output is correct |
22 | Correct | 86 ms | 2668 KB | Output is correct |
23 | Correct | 86 ms | 2640 KB | Output is correct |
24 | Correct | 86 ms | 2640 KB | Output is correct |