# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
554879 | 2022-04-29T14:15:48 Z | d4xn | Stove (JOI18_stove) | C++17 | 21 ms | 2880 KB |
#pragma GCC optimize ("Ofast") //#pragma GCC target ("avx2") #include <bits/stdc++.h> using namespace std; #define int long long #define ll long long #define ull unsigned long long #define ld long double #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define LB lower_bound #define UB upper_bound #define ii pair<int, int> #define ff first #define ss second #define mp make_pair #define pb push_back #define vi vector<int> #define vvi vector<vi> #define vb vector<bool> #define vvb vector<vb> #define vs vector<string> #define vii vector<ii> #define vvii vector<vii> #define vll vector<ll> #define vld vector<ld> #define pld pair<ld, ld> #define vpld vector<pair<ld, ld>> int n, k; vi v; signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); cin >> n >> k; v.resize(n); for (int &i : v) cin >> i; sort(all(v)); vi dis(n-1); for (int i = 0; i+1 < n; i++) { dis[i] = v[i+1] - v[i] - 1; } sort(rall(dis)); vb vis(n, 0); int ans = n; int x = n; while (k < x) { assert(x-1 == dis.size()); ans += dis[x-2]; dis.pop_back(); x--; } cout << ans << "\n"; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 316 KB | Output is correct |
4 | Correct | 1 ms | 320 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 324 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 316 KB | Output is correct |
4 | Correct | 1 ms | 320 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 324 KB | Output is correct |
10 | Correct | 1 ms | 340 KB | Output is correct |
11 | Correct | 1 ms | 340 KB | Output is correct |
12 | Correct | 1 ms | 340 KB | Output is correct |
13 | Correct | 1 ms | 340 KB | Output is correct |
14 | Correct | 1 ms | 340 KB | Output is correct |
15 | Correct | 1 ms | 340 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 316 KB | Output is correct |
4 | Correct | 1 ms | 320 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 324 KB | Output is correct |
10 | Correct | 1 ms | 340 KB | Output is correct |
11 | Correct | 1 ms | 340 KB | Output is correct |
12 | Correct | 1 ms | 340 KB | Output is correct |
13 | Correct | 1 ms | 340 KB | Output is correct |
14 | Correct | 1 ms | 340 KB | Output is correct |
15 | Correct | 1 ms | 340 KB | Output is correct |
16 | Correct | 21 ms | 2840 KB | Output is correct |
17 | Correct | 20 ms | 2772 KB | Output is correct |
18 | Correct | 19 ms | 2764 KB | Output is correct |
19 | Correct | 20 ms | 2764 KB | Output is correct |
20 | Correct | 18 ms | 2764 KB | Output is correct |
21 | Correct | 19 ms | 2880 KB | Output is correct |
22 | Correct | 19 ms | 2760 KB | Output is correct |
23 | Correct | 21 ms | 2768 KB | Output is correct |
24 | Correct | 20 ms | 2760 KB | Output is correct |