Submission #528322

# Submission time Handle Problem Language Result Execution time Memory
528322 2022-02-20T01:23:20 Z jiahng Stove (JOI18_stove) C++14
100 / 100
19 ms 3208 KB
#include <bits/stdc++.h>
using namespace std;

#define int ll
typedef long long ll;
typedef pair<int,int> pi;
typedef vector <ll> vi;
typedef vector <pi> vpi;
typedef pair<pi, ll> pii;
typedef set <ll> si;
typedef long double ld;
#define f first
#define s second
#define mp make_pair
#define FOR(i,s,e) for(int i=s;i<=int(e);++i)
#define DEC(i,s,e) for(int i=s;i>=int(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MOD 1000000007
#define maxn 100001
//~ #define getchar_unlocked _getchar_nolock

int N,K,T[maxn];

int32_t main() {
    fast;
    cin >> N >> K;
	FOR(i,1,N) cin >> T[i];
	vi ranges;
	FOR(i,1,N-1) ranges.pb(T[i+1] - T[i] - 1);
	
	int ans = N;
	sort(all(ranges));
	FOR(i,0,N-K-1) ans += ranges[i];
	cout << ans;
}

# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 1 ms 216 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 324 KB Output is correct
5 Correct 1 ms 324 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 320 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 1 ms 216 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 324 KB Output is correct
5 Correct 1 ms 324 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 320 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 1 ms 216 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 324 KB Output is correct
5 Correct 1 ms 324 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 320 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 17 ms 3132 KB Output is correct
17 Correct 17 ms 3140 KB Output is correct
18 Correct 19 ms 3148 KB Output is correct
19 Correct 19 ms 3156 KB Output is correct
20 Correct 17 ms 3152 KB Output is correct
21 Correct 18 ms 3208 KB Output is correct
22 Correct 17 ms 3124 KB Output is correct
23 Correct 18 ms 3192 KB Output is correct
24 Correct 17 ms 3140 KB Output is correct