Submission #564065

# Submission time Handle Problem Language Result Execution time Memory
564065 2022-05-18T14:00:00 Z Trisanu_Das Stove (JOI18_stove) C++17
100 / 100
65 ms 2196 KB
#include <bits/stdc++.h>
using namespace std;
 
// difficulty: cakewalk if u know there is a thing called priority queue
 
int main(){
  int n, k; cin >> n >> k;
  priority_queue<int, vector<int>, greater<int> >  times;
  int a[n];
  int ans = n;
  for(int i = 0; i < n; i++){
    cin >> a[i];
    if(i > 0) times.push(a[i] - a[i - 1] - 1);
  }
  k = n - k;
  while(k > 0 && !times.empty()){
    ans += times.top(); times.pop(); k--;
  }
  cout << ans << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 296 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 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 1 ms 212 KB Output is correct
8 Correct 1 ms 296 KB Output is correct
9 Correct 1 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 296 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 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 1 ms 212 KB Output is correct
8 Correct 1 ms 296 KB Output is correct
9 Correct 1 ms 212 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 348 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 3 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 296 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 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 1 ms 212 KB Output is correct
8 Correct 1 ms 296 KB Output is correct
9 Correct 1 ms 212 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 348 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 3 ms 468 KB Output is correct
16 Correct 61 ms 2132 KB Output is correct
17 Correct 65 ms 2116 KB Output is correct
18 Correct 54 ms 2124 KB Output is correct
19 Correct 52 ms 2116 KB Output is correct
20 Correct 51 ms 2120 KB Output is correct
21 Correct 45 ms 2192 KB Output is correct
22 Correct 43 ms 2176 KB Output is correct
23 Correct 42 ms 2196 KB Output is correct
24 Correct 45 ms 2084 KB Output is correct