# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1017864 | 2024-07-09T10:50:11 Z | vjudge1 | Stove (JOI18_stove) | C++17 | 45 ms | 3136 KB |
#include <bits/stdc++.h> #define int long long #define Aiko ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); #define pb push_back using namespace std; const int INF=1e18; signed main(){ int n, i, k, j, ans1=0, mn=0, mx=-INF, ans3=0; cin>>n>>k; int a[n+1]; int ans[n+1]; int sum[n+1]; for(i=1;i<=n;i++){ cin>>a[i]; } if(k==1)cout<<a[n]+1-a[1]; else if(n<=k)cout<<n; else{ sum[0]=0; vector<int>v; for(i=1;i<n;i++){ v.pb(a[i+1]-a[i]-1); } int ans11=a[n]-a[1]+1; sort(v.begin(),v.end()); reverse(v.begin(),v.end()); for(i=0;i<k-1;i++){ ans11-=v[i]; } cout<<ans11; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 344 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 344 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 1 ms | 348 KB | Output is correct |
11 | Correct | 1 ms | 344 KB | Output is correct |
12 | Correct | 1 ms | 348 KB | Output is correct |
13 | Correct | 1 ms | 348 KB | Output is correct |
14 | Correct | 1 ms | 348 KB | Output is correct |
15 | Correct | 1 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 344 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 1 ms | 348 KB | Output is correct |
11 | Correct | 1 ms | 344 KB | Output is correct |
12 | Correct | 1 ms | 348 KB | Output is correct |
13 | Correct | 1 ms | 348 KB | Output is correct |
14 | Correct | 1 ms | 348 KB | Output is correct |
15 | Correct | 1 ms | 348 KB | Output is correct |
16 | Correct | 30 ms | 3020 KB | Output is correct |
17 | Correct | 45 ms | 3016 KB | Output is correct |
18 | Correct | 30 ms | 3128 KB | Output is correct |
19 | Correct | 33 ms | 3016 KB | Output is correct |
20 | Correct | 30 ms | 3020 KB | Output is correct |
21 | Correct | 36 ms | 3120 KB | Output is correct |
22 | Correct | 30 ms | 3136 KB | Output is correct |
23 | Correct | 30 ms | 3028 KB | Output is correct |
24 | Correct | 45 ms | 3128 KB | Output is correct |