# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
737272 | 2023-05-07T03:47:03 Z | Amaarsaa | Stove (JOI18_stove) | C++14 | 58 ms | 3136 KB |
#include<bits/stdc++.h> using namespace std; int main() { long long n, m, ans, x, y, i, j; cin >> n >> m; long long a[n + 2]; ans = 0; vector < long long > v; for ( i = 1; i <= n; i ++) { cin >> a[i]; if ( i > 1) { v.push_back(a[i] - a[i - 1]); } } m= min(n , m); ans = a[n] - a[1] + 1; sort (v.begin(), v.end()); for (i = n - 2; i >= n -1- (m - 1); i --) { ans -= (v[i] - 1); } cout << ans << endl; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 0 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 | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 0 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 | 3 ms | 312 KB | Output is correct |
11 | Correct | 2 ms | 340 KB | Output is correct |
12 | Correct | 2 ms | 312 KB | Output is correct |
13 | Correct | 3 ms | 340 KB | Output is correct |
14 | Correct | 2 ms | 308 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 | 1 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 0 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 | 3 ms | 312 KB | Output is correct |
11 | Correct | 2 ms | 340 KB | Output is correct |
12 | Correct | 2 ms | 312 KB | Output is correct |
13 | Correct | 3 ms | 340 KB | Output is correct |
14 | Correct | 2 ms | 308 KB | Output is correct |
15 | Correct | 2 ms | 340 KB | Output is correct |
16 | Correct | 48 ms | 3076 KB | Output is correct |
17 | Correct | 48 ms | 3136 KB | Output is correct |
18 | Correct | 46 ms | 3028 KB | Output is correct |
19 | Correct | 43 ms | 3004 KB | Output is correct |
20 | Correct | 46 ms | 3048 KB | Output is correct |
21 | Correct | 58 ms | 3080 KB | Output is correct |
22 | Correct | 46 ms | 2984 KB | Output is correct |
23 | Correct | 44 ms | 2988 KB | Output is correct |
24 | Correct | 46 ms | 3124 KB | Output is correct |