Submission #749321

# Submission time Handle Problem Language Result Execution time Memory
749321 2023-05-27T18:20:45 Z tch1cherin Stove (JOI18_stove) C++17
100 / 100
46 ms 2044 KB
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> T(N);
  for (int &v : T) {
    cin >> v;
  }
  vector<int> D(N - 1);
  for (int i = 0; i < N - 1; i++) {
    D[i] = T[i + 1] - T[i] - 1;
  }
  sort(D.rbegin(), D.rend());
  cout << T[N - 1] - T[0] + 1 - accumulate(D.begin(), D.begin() + K - 1, 0) << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 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 296 KB Output is correct
7 Correct 0 ms 300 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 304 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 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 296 KB Output is correct
7 Correct 0 ms 300 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 304 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 2 ms 316 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 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 296 KB Output is correct
7 Correct 0 ms 300 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 304 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 2 ms 316 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
16 Correct 46 ms 2040 KB Output is correct
17 Correct 41 ms 1956 KB Output is correct
18 Correct 41 ms 1960 KB Output is correct
19 Correct 42 ms 2036 KB Output is correct
20 Correct 45 ms 2028 KB Output is correct
21 Correct 43 ms 1956 KB Output is correct
22 Correct 43 ms 1992 KB Output is correct
23 Correct 42 ms 2044 KB Output is correct
24 Correct 46 ms 1968 KB Output is correct