답안 #154699

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
154699 2019-09-23T14:47:48 Z jovan_b Stove (JOI18_stove) C++17
100 / 100
26 ms 2168 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;

int niz[100005];
int g[100005];

int main(){
    ios_base::sync_with_stdio(false);
    cout.precision(10);
    cout<<fixed;

    int n, k;
    cin >> n >> k;
    k--;
    for(int i=1; i<=n; i++){
        cin >> niz[i];
    }
    for(int i=2; i<=n; i++){
        g[i] = niz[i] - niz[i-1] - 1;
    }
    sort(g+1, g+1+n);
    reverse(g+1, g+1+n);
    int res = niz[n]+1-niz[1];
    for(int i=1; i<=k; i++) res -= g[i];
    cout << res;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 352 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 424 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 3 ms 376 KB Output is correct
8 Correct 2 ms 380 KB Output is correct
9 Correct 2 ms 380 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 352 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 424 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 3 ms 376 KB Output is correct
8 Correct 2 ms 380 KB Output is correct
9 Correct 2 ms 380 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 248 KB Output is correct
13 Correct 4 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 376 KB Output is correct
2 Correct 3 ms 352 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 424 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 3 ms 376 KB Output is correct
8 Correct 2 ms 380 KB Output is correct
9 Correct 2 ms 380 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 248 KB Output is correct
13 Correct 4 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 25 ms 2040 KB Output is correct
17 Correct 25 ms 2040 KB Output is correct
18 Correct 25 ms 2040 KB Output is correct
19 Correct 25 ms 2040 KB Output is correct
20 Correct 25 ms 2040 KB Output is correct
21 Correct 25 ms 2040 KB Output is correct
22 Correct 26 ms 2168 KB Output is correct
23 Correct 25 ms 2040 KB Output is correct
24 Correct 25 ms 2040 KB Output is correct