Submission #768914

# Submission time Handle Problem Language Result Execution time Memory
768914 2023-06-28T21:39:20 Z aldgebu Stove (JOI18_stove) C++14
100 / 100
15 ms 1856 KB
#include <iostream>
#include <algorithm>
#include <stack>
#include <vector>
#include <set>
#include <cstring>
#include <queue>
#include <map>
#include <cmath>
#define aldgebu return
#define ff first
#define sc second
#define pb push_back
#define pii pair <int,int>
#define p push
#define ll long long
#define pll pair<ll, ll>
#define Nptr nullptr
using namespace std;
const ll inf = 1e9;
const ll mod = 1000000000 + 7;


void Dontfuckedup(){
    int N, K;
    cin >> N >> K;

    vector <int> v;
    int prev, cur;
    cin >> prev;
    for (int i = 2; i <= N; i++){
        cin >> cur;
        v.pb(cur - prev);
        prev = cur;
    }

    sort(v.begin(), v.end());
    ll ans = N;
    for (int i = 0; i < N - K; i++){
        ans += v[i] - 1;
    }
    cout << ans;
}
 
int32_t main () {
 
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
 
    int T = 1; //cin>>T;
    while (T--)Dontfuckedup();
 
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 14 ms 984 KB Output is correct
17 Correct 15 ms 1788 KB Output is correct
18 Correct 14 ms 1852 KB Output is correct
19 Correct 14 ms 1752 KB Output is correct
20 Correct 14 ms 1752 KB Output is correct
21 Correct 14 ms 1740 KB Output is correct
22 Correct 14 ms 1752 KB Output is correct
23 Correct 14 ms 1752 KB Output is correct
24 Correct 14 ms 1856 KB Output is correct