# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1112665 | 2024-11-14T14:17:16 Z | kzhi | Stove (JOI18_stove) | C++14 | 21 ms | 2300 KB |
/* Author : kmv a.k.a kzhi K41 IT CHV */ #include <bits/stdc++.h> using namespace std; //#define int long long #define ll long long #define FOR(i,a,b) for (int i = a ; i <= b; ++ i) #define FOD(i,a,b) for (int i = a; i >= b; -- i) #define BIT(mask,i) ((mask >> i) & 1) #define MASK(i) (1ll << (i)) #define OFFBIT(mask,i) (mask &~(1ll<<(i))) #define ONBIT(mask,i) (mask | (1ll << (i))) #define lg2(x) (63 - __builtin_clzll(x)) #define c_bit __builtin_popcountll #define vi vector < int > #define all(a) a.begin(), a.end() #define pb push_back #define ii pair<int,int> #define fi first #define se second #define openfile(TASK) if (fopen(TASK".inp","r"))\ {freopen(TASK".inp","r",stdin);freopen(TASK".out","w",stdout);} #define endl '\n' #define Faster ios_base::sync_with_stdio(false); \ cin.tie(0); cout.tie(0); #define mid(l,r) ((l + r) >> 1) #define left(id) (id << 1) #define right(id) ((id << 1) | 1) #define ci const int template <class X, class Y> bool maximize(X &a, const Y &b){if(a < b) return a = b, true;return false;} template <class X, class Y> bool minimize(X &a, const Y &b){if(a > b) return a = b, true;return false;} const int N = 1e5 + 5; int n, k; int a[N]; int v[N]; void SOLVE(){ cin >> n >> k; k --; FOR (i, 1, n){ cin >> a[i]; if (i > 1) v[i - 1] = a[i] - a[i - 1] - 1; } int res = a[n] + 1 - a[1]; sort(v + 1, v + n); for (int i = 1; i <= k; i ++){ int pos = n - i; if (pos <= 0) break; res -= v[pos]; } cout << res; } signed main(){ Faster openfile("stove") int q = 1; // cin >> q; while (q --){ SOLVE(); } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 336 KB | Output is correct |
2 | Correct | 1 ms | 336 KB | Output is correct |
3 | Correct | 1 ms | 336 KB | Output is correct |
4 | Correct | 1 ms | 336 KB | Output is correct |
5 | Correct | 1 ms | 336 KB | Output is correct |
6 | Correct | 1 ms | 336 KB | Output is correct |
7 | Correct | 1 ms | 336 KB | Output is correct |
8 | Correct | 1 ms | 336 KB | Output is correct |
9 | Correct | 1 ms | 336 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 336 KB | Output is correct |
2 | Correct | 1 ms | 336 KB | Output is correct |
3 | Correct | 1 ms | 336 KB | Output is correct |
4 | Correct | 1 ms | 336 KB | Output is correct |
5 | Correct | 1 ms | 336 KB | Output is correct |
6 | Correct | 1 ms | 336 KB | Output is correct |
7 | Correct | 1 ms | 336 KB | Output is correct |
8 | Correct | 1 ms | 336 KB | Output is correct |
9 | Correct | 1 ms | 336 KB | Output is correct |
10 | Correct | 2 ms | 336 KB | Output is correct |
11 | Correct | 2 ms | 516 KB | Output is correct |
12 | Correct | 1 ms | 336 KB | Output is correct |
13 | Correct | 2 ms | 524 KB | Output is correct |
14 | Correct | 2 ms | 336 KB | Output is correct |
15 | Correct | 1 ms | 336 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 336 KB | Output is correct |
2 | Correct | 1 ms | 336 KB | Output is correct |
3 | Correct | 1 ms | 336 KB | Output is correct |
4 | Correct | 1 ms | 336 KB | Output is correct |
5 | Correct | 1 ms | 336 KB | Output is correct |
6 | Correct | 1 ms | 336 KB | Output is correct |
7 | Correct | 1 ms | 336 KB | Output is correct |
8 | Correct | 1 ms | 336 KB | Output is correct |
9 | Correct | 1 ms | 336 KB | Output is correct |
10 | Correct | 2 ms | 336 KB | Output is correct |
11 | Correct | 2 ms | 516 KB | Output is correct |
12 | Correct | 1 ms | 336 KB | Output is correct |
13 | Correct | 2 ms | 524 KB | Output is correct |
14 | Correct | 2 ms | 336 KB | Output is correct |
15 | Correct | 1 ms | 336 KB | Output is correct |
16 | Correct | 14 ms | 2128 KB | Output is correct |
17 | Correct | 14 ms | 2000 KB | Output is correct |
18 | Correct | 14 ms | 2128 KB | Output is correct |
19 | Correct | 14 ms | 2300 KB | Output is correct |
20 | Correct | 16 ms | 2140 KB | Output is correct |
21 | Correct | 14 ms | 2128 KB | Output is correct |
22 | Correct | 21 ms | 2212 KB | Output is correct |
23 | Correct | 14 ms | 2140 KB | Output is correct |
24 | Correct | 14 ms | 2128 KB | Output is correct |