# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
875626 | 2023-11-20T08:44:13 Z | TahirAliyev | Stove (JOI18_stove) | C++17 | 0 ms | 348 KB |
#include <bits/stdc++.h> using namespace std; #define ll long long int #define pii pair<int, int> #define oo 1e9 const int MAX = 1e5 + 5; int n, k; int arr[MAX]; vector<int> v; int main(){ cin >> n >> k; for(int i = 1; i <= n; i++){ cin >> arr[i]; arr[i] -= arr[1]; arr[i]++; } for(int i = 1; i <= n; i++){ if(arr[i] - arr[i - 1] - 1 > 0){ v.push_back(arr[i] - arr[i - 1] - 1); } } if(k >= v.size() + 1){ cout << n << '\n'; return 0; } sort(v.begin(), v.end()); int ans = n; for(int i = 0; i < v.size() + 1 - k; i++){ ans += v[i]; } cout << ans << '\n'; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Incorrect | 0 ms | 348 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Incorrect | 0 ms | 348 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Incorrect | 0 ms | 348 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |