# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
769337 | 2023-06-29T12:30:01 Z | Mery2005 | Stove (JOI18_stove) | C++14 | 1 ms | 340 KB |
#include <iostream> #include <algorithm> #include <queue> #include <cmath> #include <vector> #include <list> #include <string> #include <unordered_map> #include <map> #include <set> #include <stack> #include <string> #include <iomanip> #include <fstream> using namespace std; void fastio() { ios_base::sync_with_stdio(false); cin.tie(0); } const long long mod = 1e9+7; const int N = 3e6+5; int a[N] , dp[N]; void solve(){ int n , k; cin >> n >> k; for(int i = 1 ; i <= n ; i++){ cin >> a[i]; } sort(a + 1 , a + n + 1); vector<int> v; int start = a[1]; for(int i = 2 ; i <= n ; i++){ if(a[i] - start != 1){ v.push_back(a[i] - start - 1); } start = a[i]; } sort(v.begin() , v.end()); long long int ans = n * 1ll; for(int i = 0 ; i < (v.size()-k + 1) ; i++){ ans += v[i] * 1ll; } cout << ans << endl; } int main(){ solve(); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Runtime error | 1 ms | 340 KB | Execution killed with signal 11 |
6 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Runtime error | 1 ms | 340 KB | Execution killed with signal 11 |
6 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Runtime error | 1 ms | 340 KB | Execution killed with signal 11 |
6 | Halted | 0 ms | 0 KB | - |