Submission #66721

# Submission time Handle Problem Language Result Execution time Memory
66721 2018-08-12T07:30:07 Z cdemirer Stove (JOI18_stove) C++17
100 / 100
93 ms 5884 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef vector<vi> vvi;
typedef pair<double, double> dodo;
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)


int N, K;
int arr[100000];

int main(int argc, char **argv) {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		cin >> arr[i];
	}
	multiset<int> MS;
	for (int i = 0; i < N-1; i++) {
		MS.insert(arr[i+1] - arr[i] - 1);
	}
	K = N-K;
	int ans = N;
	while (K--) {
		ans += *MS.begin();
		MS.erase(MS.begin());
	}
	cout << ans << endl;
	
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 484 KB Output is correct
3 Correct 3 ms 564 KB Output is correct
4 Correct 3 ms 564 KB Output is correct
5 Correct 2 ms 620 KB Output is correct
6 Correct 2 ms 620 KB Output is correct
7 Correct 2 ms 628 KB Output is correct
8 Correct 3 ms 628 KB Output is correct
9 Correct 3 ms 628 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 484 KB Output is correct
3 Correct 3 ms 564 KB Output is correct
4 Correct 3 ms 564 KB Output is correct
5 Correct 2 ms 620 KB Output is correct
6 Correct 2 ms 620 KB Output is correct
7 Correct 2 ms 628 KB Output is correct
8 Correct 3 ms 628 KB Output is correct
9 Correct 3 ms 628 KB Output is correct
10 Correct 3 ms 672 KB Output is correct
11 Correct 3 ms 716 KB Output is correct
12 Correct 4 ms 764 KB Output is correct
13 Correct 3 ms 764 KB Output is correct
14 Correct 4 ms 764 KB Output is correct
15 Correct 3 ms 764 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 484 KB Output is correct
3 Correct 3 ms 564 KB Output is correct
4 Correct 3 ms 564 KB Output is correct
5 Correct 2 ms 620 KB Output is correct
6 Correct 2 ms 620 KB Output is correct
7 Correct 2 ms 628 KB Output is correct
8 Correct 3 ms 628 KB Output is correct
9 Correct 3 ms 628 KB Output is correct
10 Correct 3 ms 672 KB Output is correct
11 Correct 3 ms 716 KB Output is correct
12 Correct 4 ms 764 KB Output is correct
13 Correct 3 ms 764 KB Output is correct
14 Correct 4 ms 764 KB Output is correct
15 Correct 3 ms 764 KB Output is correct
16 Correct 83 ms 5628 KB Output is correct
17 Correct 78 ms 5628 KB Output is correct
18 Correct 84 ms 5732 KB Output is correct
19 Correct 73 ms 5732 KB Output is correct
20 Correct 93 ms 5732 KB Output is correct
21 Correct 80 ms 5732 KB Output is correct
22 Correct 89 ms 5884 KB Output is correct
23 Correct 77 ms 5884 KB Output is correct
24 Correct 88 ms 5884 KB Output is correct