Submission #124331

# Submission time Handle Problem Language Result Execution time Memory
124331 2019-07-03T05:50:02 Z rajarshi_basu Stove (JOI18_stove) C++14
0 / 100
2 ms 376 KB
#include <iostream>
#include <vector>
#include <set>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <stdio.h>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <fstream>
#include <complex>
#include <stack>
#include <set>

#define FOR(i,n) for(int i=0;i<n;i++)
#define FORE(i,a,b) for(int i=a;i<=b;i++)
#define ll long long int
#define vi vector<int>
#define ii pair<int,int>
#define pb push_back
#define mp make_pair
#define vv vector
#define ff first
#define ss second
#define pll pair<ll,ll>
#define cd complex<double> 
#define ld long double
#define pld pair<ld,ld>
#define iii pair<ii,int>

using namespace std;

const int INF = 1e9;
const int MAXN = 1e5;
const int MAXK = 100+10;

int main(){
	int n,k;
	cin >> n >> k;
	vi all;
	FOR(i,n){
		int a;cin >> a;
		all.pb(a);
	}
	sort(all.begin(), all.end());
	int tot = all.back() - all.front() + 1;
	vi diff;
	FORE(i,1,n-1){
		diff.pb(all[i]-all[i-1] - 1);
	}
	sort(diff.begin(), diff.end(),greater<int>());
	FOR(j,n-1-k){
		tot -= diff[j];
	}
	cout << tot << endl;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -