# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
127218 | 2019-07-09T06:50:41 Z | nhimnam120 | Stove (JOI18_stove) | C++14 | 31 ms | 3312 KB |
#include<bits/stdc++.h> using namespace std; vector<long long> inp; vector<long long> pro; signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); 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 | 380 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 | 376 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 | 380 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 | 376 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 | 3 ms | 376 KB | Output is correct |
11 | Correct | 3 ms | 504 KB | Output is correct |
12 | Correct | 3 ms | 504 KB | Output is correct |
13 | Correct | 3 ms | 376 KB | Output is correct |
14 | Correct | 3 ms | 552 KB | Output is correct |
15 | Correct | 3 ms | 376 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 380 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 | 376 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 | 3 ms | 376 KB | Output is correct |
11 | Correct | 3 ms | 504 KB | Output is correct |
12 | Correct | 3 ms | 504 KB | Output is correct |
13 | Correct | 3 ms | 376 KB | Output is correct |
14 | Correct | 3 ms | 552 KB | Output is correct |
15 | Correct | 3 ms | 376 KB | Output is correct |
16 | Correct | 31 ms | 3184 KB | Output is correct |
17 | Correct | 31 ms | 3184 KB | Output is correct |
18 | Correct | 28 ms | 3308 KB | Output is correct |
19 | Correct | 29 ms | 3304 KB | Output is correct |
20 | Correct | 29 ms | 3180 KB | Output is correct |
21 | Correct | 29 ms | 3308 KB | Output is correct |
22 | Correct | 29 ms | 3308 KB | Output is correct |
23 | Correct | 29 ms | 3308 KB | Output is correct |
24 | Correct | 28 ms | 3312 KB | Output is correct |