# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
127205 | 2019-07-09T06:40:46 Z | MrUnknown | Stove (JOI18_stove) | C++11 | 28 ms | 2292 KB |
/*** * __ __ _ _ _ * | \/ | | | | | | | * | \ / |_ __ | | | |_ __ | | ___ __ _____ ___ __ * | |\/| | '__| | | | | '_ \| |/ / '_ \ / _ \ \ /\ / / '_ \ * | | | | | _ | |__| | | | | <| | | | (_) \ V V /| | | | * |_| |_|_| (_) \____/|_| |_|_|\_\_| |_|\___/ \_/\_/ |_| |_| * * */ #include<stdio.h> #include<bits/stdc++.h> using namespace std; #define ll long long #define f(i,a,b) for (int i=a;i<=b;i++) #define f_(i,a,b) for (int i=a;i>=b;i--) #define ii pair<int,int> #define iii pair<int,ii> #define MP make_pair int n,a[100005],k,ans; vector<int> v; int main() { // freopen("","r",stdin); // freopen("","w",stdout); scanf("%d %d", &n, &k); f(i,1,n) scanf("%d", &a[i]); if (k>=n) printf("%d", n); else { ans=n; f(i,2,n) v.push_back(a[i]-a[i-1]-1); sort(v.begin(),v.end()); f(i,1,n-k) ans+=v[i-1]; printf("%d", ans); } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 380 KB | Output is correct |
2 | Correct | 2 ms | 376 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 | 256 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 256 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Correct | 2 ms | 256 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 380 KB | Output is correct |
2 | Correct | 2 ms | 376 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 | 256 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 256 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Correct | 2 ms | 256 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 | 376 KB | Output is correct |
14 | Correct | 3 ms | 376 KB | Output is correct |
15 | Correct | 3 ms | 376 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 380 KB | Output is correct |
2 | Correct | 2 ms | 376 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 | 256 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 256 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Correct | 2 ms | 256 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 | 376 KB | Output is correct |
14 | Correct | 3 ms | 376 KB | Output is correct |
15 | Correct | 3 ms | 376 KB | Output is correct |
16 | Correct | 28 ms | 2292 KB | Output is correct |
17 | Correct | 27 ms | 2292 KB | Output is correct |
18 | Correct | 28 ms | 2292 KB | Output is correct |
19 | Correct | 28 ms | 2292 KB | Output is correct |
20 | Correct | 28 ms | 2292 KB | Output is correct |
21 | Correct | 28 ms | 2292 KB | Output is correct |
22 | Correct | 27 ms | 2264 KB | Output is correct |
23 | Correct | 27 ms | 2292 KB | Output is correct |
24 | Correct | 28 ms | 2292 KB | Output is correct |