# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
223720 |
2020-04-16T08:02:47 Z |
bharat2002 |
Stove (JOI18_stove) |
C++14 |
|
5 ms |
384 KB |
/*input
3 2
1
3
6
*/
#include<bits/stdc++.h>
using namespace std;
const int N=1e5 + 100;
const int mod=1e9 + 7;
#define int long long
const int inf=1e18;
#define pii pair<int, int>
#define f first
#define s second
#define mp make_pair
#define FOR(i, n) for(int i=1;i<=n;i++)
#define TRACE(x) cerr << #x << " = " << x << endl
//Trace prints the name of the variable and the value.
int ans, arr[N];vector<int> vals;
signed main()
{
ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int n, k;cin>>n>>k;
for(int i=1;i<=n;i++)
{
cin>>arr[i];
if(i>1) vals.push_back(arr[i]-arr[i-1]);
}
sort(vals.begin(), vals.end());
ans=n;
for(int i=0;i<k-1;i++)
{
ans+=vals[i]-1;
}
cout<<ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |