# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
365998 | 2021-02-12T17:20:54 Z | Hades504 | Stove (JOI18_stove) | C++14 | 1000 ms | 3812 KB |
#include<bits/stdc++.h> using namespace std; #define int long long #define endl "\n" void solve(){ int tc,k; cin>>tc>>k; k--; vector<int>v,diff; for(int i=0;i<tc;i++){ int n; cin>>n; v.push_back(n); v.push_back(n+1); } int ans=0; ans+=tc; auto st = v.begin(); v.erase(st); auto end = v.end(); end--; v.erase(end); for(int i=0;i<v.size();i+=2){ diff.push_back(v[i+1]-v[i]); } sort(diff.rbegin(),diff.rend()); while(k!=0){ auto it = diff.begin(); diff.erase(it); k--; } for(int i=0;i<diff.size();i++){ ans+=diff[i]; } cout<<ans; } signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int tc=1; for(int i=0;i<tc;i++)solve(); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 512 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 0 ms | 364 KB | Output is correct |
7 | Correct | 1 ms | 364 KB | Output is correct |
8 | Correct | 1 ms | 380 KB | Output is correct |
9 | Correct | 1 ms | 364 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 512 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 0 ms | 364 KB | Output is correct |
7 | Correct | 1 ms | 364 KB | Output is correct |
8 | Correct | 1 ms | 380 KB | Output is correct |
9 | Correct | 1 ms | 364 KB | Output is correct |
10 | Correct | 1 ms | 492 KB | Output is correct |
11 | Correct | 1 ms | 492 KB | Output is correct |
12 | Correct | 2 ms | 492 KB | Output is correct |
13 | Correct | 3 ms | 492 KB | Output is correct |
14 | Correct | 2 ms | 492 KB | Output is correct |
15 | Correct | 2 ms | 492 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 512 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 0 ms | 364 KB | Output is correct |
7 | Correct | 1 ms | 364 KB | Output is correct |
8 | Correct | 1 ms | 380 KB | Output is correct |
9 | Correct | 1 ms | 364 KB | Output is correct |
10 | Correct | 1 ms | 492 KB | Output is correct |
11 | Correct | 1 ms | 492 KB | Output is correct |
12 | Correct | 2 ms | 492 KB | Output is correct |
13 | Correct | 3 ms | 492 KB | Output is correct |
14 | Correct | 2 ms | 492 KB | Output is correct |
15 | Correct | 2 ms | 492 KB | Output is correct |
16 | Correct | 24 ms | 3812 KB | Output is correct |
17 | Correct | 30 ms | 3796 KB | Output is correct |
18 | Correct | 94 ms | 3812 KB | Output is correct |
19 | Correct | 707 ms | 3812 KB | Output is correct |
20 | Execution timed out | 1055 ms | 3812 KB | Time limit exceeded |
21 | Halted | 0 ms | 0 KB | - |