Submission #545426

# Submission time Handle Problem Language Result Execution time Memory
545426 2022-04-04T13:36:56 Z LunaMeme Stove (JOI18_stove) C++14
100 / 100
49 ms 1832 KB
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> ii;
typedef vector<pair<int, int>> vii;
typedef vector<int> vi;
typedef long long ll;
#define PB push_back
#define MP make_pair
#define FOR(i, x, y) for (int i = x; i < y ; i ++)

int main(){
    int n, k; cin >> n >> k;
    int prev;
    int first;
    vi gaps;
    cin >> prev;
    first = prev;
    FOR(i, 0, n - 1){
        int num; cin >> num;
        gaps.PB(num - prev - 1);
        prev = num;
    }
    sort(gaps.rbegin(), gaps.rend());
    ll ans = prev - first + 1;
    FOR(i, 0, k - 1){
        ans -= gaps[i];
    }
    cout << ans << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 300 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 300 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 300 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 300 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 300 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 300 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 2 ms 340 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 2 ms 312 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 300 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 300 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 300 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 2 ms 340 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 2 ms 312 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
16 Correct 49 ms 1796 KB Output is correct
17 Correct 45 ms 1692 KB Output is correct
18 Correct 45 ms 1784 KB Output is correct
19 Correct 47 ms 1812 KB Output is correct
20 Correct 45 ms 1744 KB Output is correct
21 Correct 49 ms 1800 KB Output is correct
22 Correct 44 ms 1760 KB Output is correct
23 Correct 43 ms 1832 KB Output is correct
24 Correct 43 ms 1744 KB Output is correct