답안 #880186

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
880186 2023-11-29T02:23:27 Z niter Stove (JOI18_stove) C++14
100 / 100
35 ms 1596 KB
#include <bits/stdc++.h>
#define loop(i,a,b) for(int i = (a); i < (b); i ++)
#define pb push_back
#define ins insert
#define pii pair<int,int>
#define ff first
#define ss second
#define op(x) cerr << #x << " = " << x << endl;
#define opa(x) cerr << #x << " = " << x << ", ";
#define ops(x) cerr << x;
#define entr cerr << endl;
#define spac cerr << ' ';
#define STL(x) cerr << #x << " : "; for(auto &qwe:x) cerr << qwe << ' '; cerr << endl;
#define ARR(x, nnn) cerr << #x <<  " : "; loop(qwe,0,nnn) cerr << x[qwe] << ' '; cerr << endl;
#define BAE(x) x.begin(), x.end()
#define unilize(x) x.resize(unique(BAE(x)) - x.begin())
#define unisort(x) sort(BAE(x)); unilize(x);
using namespace std;

const int mxn = (int)(1e5) + 10;
int a[mxn];

int main(){
    int n, k; cin >> n >> k;
    int ans = n;
    loop(i,0,n){
        cin >> a[i];
    }
    vector<int> v;
    loop(i,1,n){
        v.pb(a[i] - a[i-1] - 1);
    }
    sort(BAE(v));
    int take = n - k;
    loop(i,0,take){
        ans += v[i];
    }
    cout << ans;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 3 ms 348 KB Output is correct
14 Correct 2 ms 448 KB Output is correct
15 Correct 2 ms 600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 3 ms 348 KB Output is correct
14 Correct 2 ms 448 KB Output is correct
15 Correct 2 ms 600 KB Output is correct
16 Correct 35 ms 1228 KB Output is correct
17 Correct 34 ms 1228 KB Output is correct
18 Correct 34 ms 1228 KB Output is correct
19 Correct 34 ms 1240 KB Output is correct
20 Correct 34 ms 1340 KB Output is correct
21 Correct 34 ms 1596 KB Output is correct
22 Correct 34 ms 1236 KB Output is correct
23 Correct 34 ms 1228 KB Output is correct
24 Correct 34 ms 1228 KB Output is correct