# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
864439 | 2023-10-23T00:29:21 Z | VN_AnhTuan | Stove (JOI18_stove) | C++14 | 471 ms | 5028 KB |
#include <bits/stdc++.h> #define fi first #define se second #define pii pair<int, int> #define mp make_pair #define pb push_back #define bit(X,i) ((X>>i)&1) #define fori(i,d,c) for(int i = d; i <= c; ++ i) #define ford(i,d,c) for(int i = d; i >= c; -- i) #define all(V) V.begin(), V.end() #define RRH(V) V.resize(unique(all(V))-V.begin()) #define debug(x) { cerr << #x << " = "; cerr << (x) << '\n'; } #define open(Task) if (fopen(Task".inp", "r")) {freopen(Task".inp", "r", stdin);freopen(Task".out", "w", stdout);} using namespace std; using ll = long long; using ld = long double; const int maxn = 1e5 + 5; const int maxm = 1e5 + 5; const int base = 101; int n, m, a[maxn]; void read() { cin >> n >> m; m --; fori(i,1,n) cin >> a[i]; } void solve() { priority_queue<int> pq; fori(i,2,n) { pq.push(max(0,a[i] - (a[i-1] + 1))); debug(a[i] - (a[i-1] + 1)); } int res = a[n] - a[1] + 1; while(m --> 0 && !pq.empty()) { res -= pq.top(); pq.pop(); } cout << res; } int main () { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); open("stove"); read(); solve(); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 344 KB | Output is correct |
3 | Correct | 1 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 1 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 344 KB | Output is correct |
3 | Correct | 1 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 1 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 14 ms | 604 KB | Output is correct |
11 | Correct | 14 ms | 604 KB | Output is correct |
12 | Correct | 14 ms | 604 KB | Output is correct |
13 | Correct | 14 ms | 760 KB | Output is correct |
14 | Correct | 16 ms | 604 KB | Output is correct |
15 | Correct | 14 ms | 604 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 344 KB | Output is correct |
3 | Correct | 1 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 1 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 14 ms | 604 KB | Output is correct |
11 | Correct | 14 ms | 604 KB | Output is correct |
12 | Correct | 14 ms | 604 KB | Output is correct |
13 | Correct | 14 ms | 760 KB | Output is correct |
14 | Correct | 16 ms | 604 KB | Output is correct |
15 | Correct | 14 ms | 604 KB | Output is correct |
16 | Correct | 444 ms | 4676 KB | Output is correct |
17 | Correct | 442 ms | 4712 KB | Output is correct |
18 | Correct | 441 ms | 4748 KB | Output is correct |
19 | Correct | 471 ms | 4696 KB | Output is correct |
20 | Correct | 443 ms | 5028 KB | Output is correct |
21 | Correct | 450 ms | 4820 KB | Output is correct |
22 | Correct | 455 ms | 4632 KB | Output is correct |
23 | Correct | 455 ms | 4876 KB | Output is correct |
24 | Correct | 446 ms | 4720 KB | Output is correct |