Submission #1090162

# Submission time Handle Problem Language Result Execution time Memory
1090162 2024-09-17T22:48:37 Z HienTD Stove (JOI18_stove) C++14
100 / 100
16 ms 1968 KB
#include <bits/stdc++.h>
using namespace std;

//#define LOCAL

#define          	fi  first
#define             se  second
#define           TIME  (1.0 * clock() / CLOCKS_PER_SEC)
#define         ALL(v)  (v).begin(), (v).end()
#define  		BIT(x)  (1LL << (x))
#define 	MASK(x, i)  (((x) >> (i)) & 1)
#define   FOR(i, a, b)  for(int i = (a), _b = (b); i <= _b; ++ i)
#define  FORD(i, b, a)  for(int i = (b), _a = (a); i >= _a; -- i)

const string NAME = "BAITAP";

const long long INF = 1e18;
const int inf = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int mod = 998244353;

const int mxN = 1e5 + 5;

int N, K;
vector<int> d(mxN);

void init(void){
	cin >> N >> K;
	int a, b;
	FOR(i, 1, N){
		cin >> b;
		if(i > 1) d[i - 1] = b - a - 1;
		a = b;
	}
}

void process(void){
	sort(d.begin() + 1, d.begin() + N);
	int ans = N;
	FOR(i, 1, N - K) ans += d[i];
	cout << ans;
}

signed main(void){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	#ifdef LOCAL
		freopen((NAME + ".INP").c_str(), "r", stdin);
		freopen((NAME + ".OUT").c_str(), "w", stdout);
	#endif // I/O

	init();
	process();
	cerr << "\nTime elapsed: " << TIME << "s.\n";
}

# Verdict Execution time Memory Grader output
1 Correct 1 ms 860 KB Output is correct
2 Correct 0 ms 860 KB Output is correct
3 Correct 1 ms 1116 KB Output is correct
4 Correct 0 ms 860 KB Output is correct
5 Correct 0 ms 860 KB Output is correct
6 Correct 0 ms 860 KB Output is correct
7 Correct 0 ms 860 KB Output is correct
8 Correct 0 ms 860 KB Output is correct
9 Correct 1 ms 860 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 860 KB Output is correct
2 Correct 0 ms 860 KB Output is correct
3 Correct 1 ms 1116 KB Output is correct
4 Correct 0 ms 860 KB Output is correct
5 Correct 0 ms 860 KB Output is correct
6 Correct 0 ms 860 KB Output is correct
7 Correct 0 ms 860 KB Output is correct
8 Correct 0 ms 860 KB Output is correct
9 Correct 1 ms 860 KB Output is correct
10 Correct 1 ms 860 KB Output is correct
11 Correct 1 ms 860 KB Output is correct
12 Correct 1 ms 896 KB Output is correct
13 Correct 1 ms 860 KB Output is correct
14 Correct 1 ms 860 KB Output is correct
15 Correct 1 ms 860 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 860 KB Output is correct
2 Correct 0 ms 860 KB Output is correct
3 Correct 1 ms 1116 KB Output is correct
4 Correct 0 ms 860 KB Output is correct
5 Correct 0 ms 860 KB Output is correct
6 Correct 0 ms 860 KB Output is correct
7 Correct 0 ms 860 KB Output is correct
8 Correct 0 ms 860 KB Output is correct
9 Correct 1 ms 860 KB Output is correct
10 Correct 1 ms 860 KB Output is correct
11 Correct 1 ms 860 KB Output is correct
12 Correct 1 ms 896 KB Output is correct
13 Correct 1 ms 860 KB Output is correct
14 Correct 1 ms 860 KB Output is correct
15 Correct 1 ms 860 KB Output is correct
16 Correct 13 ms 1628 KB Output is correct
17 Correct 13 ms 1736 KB Output is correct
18 Correct 14 ms 1736 KB Output is correct
19 Correct 16 ms 1884 KB Output is correct
20 Correct 13 ms 1628 KB Output is correct
21 Correct 13 ms 1968 KB Output is correct
22 Correct 13 ms 1628 KB Output is correct
23 Correct 16 ms 1628 KB Output is correct
24 Correct 13 ms 1628 KB Output is correct