# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
668749 | 2022-12-04T21:19:33 Z | mseebacher | Stove (JOI18_stove) | C++17 | 18 ms | 2308 KB |
#include <bits/stdc++.h> using namespace std; typedef unsigned long long ull; typedef long long ll; typedef vector<int> vi; void setIO(string s) { freopen((s + ".in").c_str(), "r", stdin); freopen((s + ".ans").c_str(), "w", stdout); } #define MAXI (int)1e5 #define LSOne(S) ((S) & -(S)) #define MSB(S) __builtin_clz(S) void solve(){ int n,k; cin >> n >> k; int b[n]; for(int i = 0;i<n;i++){ cin >> b[i]; } ll dis = b[n-1]-b[0]+1; vector<int> diff; for(int i = 1;i<n;i++){ diff.push_back(b[i]-b[i-1]-1); } sort(diff.rbegin(),diff.rend()); for(int i = 0;i+1<k;i++){ dis -= diff[i]; } cout << dis; } int main(){ ios::sync_with_stdio(0); cin.tie(nullptr); cout << fixed << setprecision(8); int t = 1; //cin >> t; while(t){ solve(); t--; cout << "\n"; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 1 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 | 212 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 | 0 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 1 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 | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 356 KB | Output is correct |
11 | Correct | 1 ms | 340 KB | Output is correct |
12 | Correct | 1 ms | 332 KB | Output is correct |
13 | Correct | 1 ms | 332 KB | Output is correct |
14 | Correct | 1 ms | 340 KB | Output is correct |
15 | Correct | 1 ms | 360 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 1 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 | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 356 KB | Output is correct |
11 | Correct | 1 ms | 340 KB | Output is correct |
12 | Correct | 1 ms | 332 KB | Output is correct |
13 | Correct | 1 ms | 332 KB | Output is correct |
14 | Correct | 1 ms | 340 KB | Output is correct |
15 | Correct | 1 ms | 360 KB | Output is correct |
16 | Correct | 17 ms | 2220 KB | Output is correct |
17 | Correct | 17 ms | 2260 KB | Output is correct |
18 | Correct | 17 ms | 2224 KB | Output is correct |
19 | Correct | 17 ms | 2256 KB | Output is correct |
20 | Correct | 17 ms | 2228 KB | Output is correct |
21 | Correct | 17 ms | 2264 KB | Output is correct |
22 | Correct | 18 ms | 2308 KB | Output is correct |
23 | Correct | 18 ms | 2256 KB | Output is correct |
24 | Correct | 18 ms | 2264 KB | Output is correct |