Submission #333736

# Submission time Handle Problem Language Result Execution time Memory
333736 2020-12-07T15:11:03 Z bigDuck Stove (JOI18_stove) C++14
100 / 100
96 ms 6132 KB
#include<bits/stdc++.h>
using namespace std;
#define INIT  ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define mp make_pair
#define pb push_back
#define ft first
#define sc second
#define ll long long
#define pii pair<int, int>
#define count_bits __builtin_popcount
#define int ll

int t, n, m, k, a[300010], q, l, r;


int32_t main(){
INIT
cin>>n>>k;

int ft=0, lt=0;
multiset<int> ms;

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

    if(lt>0){
        ms.insert(t-lt);
    }

    if(!ft){
        ft=t;
    }
    lt=t+1;
}

int free=0;
if(!ms.empty()){
auto it=ms.end();
it--;
k--;
while(k>0 ){
    k--;
    free+=*it;
    if(it==ms.begin()){break;}
    it--;
}

}

cout<<(lt-ft-free);


return 0;
}



# Verdict Execution time Memory Grader output
1 Correct 1 ms 492 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 492 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 2 ms 492 KB Output is correct
11 Correct 1 ms 492 KB Output is correct
12 Correct 2 ms 492 KB Output is correct
13 Correct 2 ms 492 KB Output is correct
14 Correct 2 ms 492 KB Output is correct
15 Correct 2 ms 492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 492 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 2 ms 492 KB Output is correct
11 Correct 1 ms 492 KB Output is correct
12 Correct 2 ms 492 KB Output is correct
13 Correct 2 ms 492 KB Output is correct
14 Correct 2 ms 492 KB Output is correct
15 Correct 2 ms 492 KB Output is correct
16 Correct 96 ms 6124 KB Output is correct
17 Correct 96 ms 6132 KB Output is correct
18 Correct 70 ms 5996 KB Output is correct
19 Correct 56 ms 5996 KB Output is correct
20 Correct 62 ms 5996 KB Output is correct
21 Correct 67 ms 5996 KB Output is correct
22 Correct 63 ms 5996 KB Output is correct
23 Correct 65 ms 5996 KB Output is correct
24 Correct 64 ms 5996 KB Output is correct