Submission #167687

# Submission time Handle Problem Language Result Execution time Memory
167687 2019-12-09T15:41:49 Z theStaticMind Stove (JOI18_stove) C++14
100 / 100
34 ms 3360 KB
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define ii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define INF 100000000000000000
#define modulo 1000000007
#define mod 998244353
#define int long long int
using namespace std;

int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
   //   freopen("q.gir","r",stdin);
   //   freopen("q.cik","w",stdout);
      int n,k,ans=0;
      cin>>n>>k;k--;
      vector<int>arr(n);
      for(int i=0;i<n;i++)cin>>arr[i];
      ans=arr[n-1]-arr[0]+1;
      priority_queue<int>Q;
      for(int i=1;i<n;i++){
            Q.push(arr[i]-arr[i-1]-1);
      }
      while(k--){
            ans-=Q.top();
            Q.pop();
      }
      cout<<ans;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 380 KB Output is correct
10 Correct 2 ms 504 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 3 ms 504 KB Output is correct
13 Correct 3 ms 504 KB Output is correct
14 Correct 3 ms 376 KB Output is correct
15 Correct 3 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 380 KB Output is correct
10 Correct 2 ms 504 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 3 ms 504 KB Output is correct
13 Correct 3 ms 504 KB Output is correct
14 Correct 3 ms 376 KB Output is correct
15 Correct 3 ms 504 KB Output is correct
16 Correct 20 ms 3316 KB Output is correct
17 Correct 20 ms 3184 KB Output is correct
18 Correct 21 ms 3204 KB Output is correct
19 Correct 21 ms 3360 KB Output is correct
20 Correct 27 ms 3316 KB Output is correct
21 Correct 32 ms 3316 KB Output is correct
22 Correct 33 ms 3312 KB Output is correct
23 Correct 33 ms 3324 KB Output is correct
24 Correct 34 ms 3316 KB Output is correct