Submission #199196

# Submission time Handle Problem Language Result Execution time Memory
199196 2020-01-30T03:23:37 Z xiaowuc1 Stove (JOI18_stove) C++17
100 / 100
35 ms 1784 KB
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>

using namespace std;

// BEGIN NO SAD
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef vector<int> vi;
// END NO SAD

typedef long long ll;
typedef pair<int, int> pii;

int l[100005];
void solve() {
  int n, k;
  cin >> n >> k;
  for(int i = 0; i < n; i++) cin >> l[i];
  int ret = l[n-1] - l[0] + 1;
  priority_queue<int> q;
  for(int i = 1; i < n; i++) q.push(l[i] - l[i-1] - 1);
  while(k-- > 1) {
    ret -= q.top(); q.pop();
  }
  cout << ret << "\n";
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 380 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 380 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 6 ms 408 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 6 ms 380 KB Output is correct
13 Correct 6 ms 376 KB Output is correct
14 Correct 6 ms 376 KB Output is correct
15 Correct 6 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 380 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 6 ms 408 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 6 ms 380 KB Output is correct
13 Correct 6 ms 376 KB Output is correct
14 Correct 6 ms 376 KB Output is correct
15 Correct 6 ms 376 KB Output is correct
16 Correct 23 ms 1528 KB Output is correct
17 Correct 23 ms 1784 KB Output is correct
18 Correct 21 ms 1784 KB Output is correct
19 Correct 25 ms 1656 KB Output is correct
20 Correct 29 ms 1656 KB Output is correct
21 Correct 34 ms 1656 KB Output is correct
22 Correct 35 ms 1652 KB Output is correct
23 Correct 35 ms 1784 KB Output is correct
24 Correct 34 ms 1656 KB Output is correct