Submission #124332

# Submission time Handle Problem Language Result Execution time Memory
124332 2019-07-03T05:53:53 Z rajarshi_basu Stove (JOI18_stove) C++14
100 / 100
101 ms 2568 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());
	int tot = n;
	FOR(j,n-k){
		tot += diff[j];
	}
	cout << tot << endl;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 4 ms 376 KB Output is correct
11 Correct 5 ms 380 KB Output is correct
12 Correct 5 ms 376 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 4 ms 376 KB Output is correct
15 Correct 4 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 4 ms 376 KB Output is correct
11 Correct 5 ms 380 KB Output is correct
12 Correct 5 ms 376 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 4 ms 376 KB Output is correct
15 Correct 4 ms 376 KB Output is correct
16 Correct 86 ms 2416 KB Output is correct
17 Correct 101 ms 2388 KB Output is correct
18 Correct 86 ms 2412 KB Output is correct
19 Correct 85 ms 2412 KB Output is correct
20 Correct 85 ms 2540 KB Output is correct
21 Correct 87 ms 2416 KB Output is correct
22 Correct 87 ms 2416 KB Output is correct
23 Correct 85 ms 2568 KB Output is correct
24 Correct 85 ms 2420 KB Output is correct