답안 #419257

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
419257 2021-06-06T15:39:18 Z Lobo Stove (JOI18_stove) C++17
100 / 100
25 ms 1640 KB
#include <bits/stdc++.h>
 
using namespace std;

const long long INFll = 1e18;
const int INFii = 1e9;
typedef long long ll;
typedef int ii;
typedef double dbl;
#define endl '\n'
#define sc second
#define fr first
#define mp make_pair
#define pb push_back

#define maxn 110000
//LEMBRAR DE MUDAR

ii n, k, ant, g[maxn];


int main() {
    ios::sync_with_stdio(false); cin.tie(0);

    //freopen("in.in", "r", stdin);
    //freopen("____.out", "w", stdout);

    cin >> n >> k;
    cin >> ant;

    ii ans = 1;
    for(ii i = 1; i < n; i++) {
        ii t;
        cin >> t;

        g[i] = t-ant-1;
        ans+= g[i] + 1;
        ant = t;
    }

    sort(g+1,g+1+n,greater<ii>());

    k--;
    for(ii i = 1; i <= k; i++) {
        ans-= g[i];
    }

    cout << ans << endl;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 2 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 2 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 2 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 2 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 21 ms 1616 KB Output is correct
17 Correct 25 ms 1636 KB Output is correct
18 Correct 21 ms 1620 KB Output is correct
19 Correct 20 ms 1612 KB Output is correct
20 Correct 21 ms 1616 KB Output is correct
21 Correct 21 ms 1632 KB Output is correct
22 Correct 23 ms 1596 KB Output is correct
23 Correct 21 ms 1612 KB Output is correct
24 Correct 21 ms 1640 KB Output is correct