# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
330132 | 2020-11-24T03:09:28 Z | eric_xiao | Stove (JOI18_stove) | C++14 | 52 ms | 2148 KB |
#include<bits/stdc++.h> #define ll long long using namespace std; long long A[500000]; vector<ll> te; int main() { ll N,M,i,j,k; cin >> N >> k; for(i = 0;i < N;i++) { cin >> A[i]; if(i > 0) te.push_back(A[i]-A[i-1]-1); } ll ans = A[N-1]-A[0]+1; sort(te.begin(),te.end()); reverse(te.begin(),te.end()); for(i = 0;i < k-1;i++) { ans -= te[i]; } cout << ans << endl; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 0 ms | 364 KB | Output is correct |
4 | Correct | 0 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 | 0 ms | 364 KB | Output is correct |
9 | Correct | 0 ms | 364 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 0 ms | 364 KB | Output is correct |
4 | Correct | 0 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 | 0 ms | 364 KB | Output is correct |
9 | Correct | 0 ms | 364 KB | Output is correct |
10 | Correct | 2 ms | 364 KB | Output is correct |
11 | Correct | 2 ms | 364 KB | Output is correct |
12 | Correct | 2 ms | 364 KB | Output is correct |
13 | Correct | 2 ms | 364 KB | Output is correct |
14 | Correct | 2 ms | 364 KB | Output is correct |
15 | Correct | 2 ms | 364 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 0 ms | 364 KB | Output is correct |
4 | Correct | 0 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 | 0 ms | 364 KB | Output is correct |
9 | Correct | 0 ms | 364 KB | Output is correct |
10 | Correct | 2 ms | 364 KB | Output is correct |
11 | Correct | 2 ms | 364 KB | Output is correct |
12 | Correct | 2 ms | 364 KB | Output is correct |
13 | Correct | 2 ms | 364 KB | Output is correct |
14 | Correct | 2 ms | 364 KB | Output is correct |
15 | Correct | 2 ms | 364 KB | Output is correct |
16 | Correct | 50 ms | 2020 KB | Output is correct |
17 | Correct | 51 ms | 2020 KB | Output is correct |
18 | Correct | 51 ms | 2020 KB | Output is correct |
19 | Correct | 50 ms | 2020 KB | Output is correct |
20 | Correct | 51 ms | 2020 KB | Output is correct |
21 | Correct | 52 ms | 2020 KB | Output is correct |
22 | Correct | 50 ms | 2020 KB | Output is correct |
23 | Correct | 52 ms | 2020 KB | Output is correct |
24 | Correct | 50 ms | 2148 KB | Output is correct |