# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
854343 | 2023-09-27T00:44:53 Z | dungz | Stove (JOI18_stove) | C++17 | 2 ms | 344 KB |
#include<bits/stdc++.h> #define ll long long #define fo(i,a,b) for(int i=a;i<=b;++i) #define fod(i,a,b) for(int i=a;i>=b;--i) #define fi first #define se second #define task "stove" using namespace std; const int N=1e5+5; const ll oo=1e18; const int base=311; int n,k; int a[N]; int ans; vector<int>vec; int main() { ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); freopen(task".inp","r",stdin); freopen(task".out","w",stdout); cin>>n>>k; fo(i,1,n)cin>>a[i]; ans=a[n]+1-a[1]; fo(i,1,n-1) vec.emplace_back(a[i+1]-a[i]-1); sort(vec.begin(),vec.end()); fod(i,vec.size()-1, 0) { if(k==1)break; ans-=vec[i]; k--; } cout<<ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 344 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 344 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 344 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |