# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
867971 | 2023-10-30T02:18:44 Z | VN_AnhTuan | Stove (JOI18_stove) | C++14 | 21 ms | 2408 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))); } 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 | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 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 | 0 ms | 460 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 1 ms | 348 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 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 | 0 ms | 460 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 1 ms | 348 KB | Output is correct |
10 | Correct | 1 ms | 600 KB | Output is correct |
11 | Correct | 1 ms | 348 KB | Output is correct |
12 | Correct | 1 ms | 348 KB | Output is correct |
13 | Correct | 1 ms | 348 KB | Output is correct |
14 | Correct | 1 ms | 348 KB | Output is correct |
15 | Correct | 1 ms | 348 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 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 | 0 ms | 460 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 1 ms | 348 KB | Output is correct |
10 | Correct | 1 ms | 600 KB | Output is correct |
11 | Correct | 1 ms | 348 KB | Output is correct |
12 | Correct | 1 ms | 348 KB | Output is correct |
13 | Correct | 1 ms | 348 KB | Output is correct |
14 | Correct | 1 ms | 348 KB | Output is correct |
15 | Correct | 1 ms | 348 KB | Output is correct |
16 | Correct | 10 ms | 2272 KB | Output is correct |
17 | Correct | 9 ms | 2408 KB | Output is correct |
18 | Correct | 10 ms | 2360 KB | Output is correct |
19 | Correct | 13 ms | 2272 KB | Output is correct |
20 | Correct | 15 ms | 2324 KB | Output is correct |
21 | Correct | 21 ms | 2272 KB | Output is correct |
22 | Correct | 18 ms | 2268 KB | Output is correct |
23 | Correct | 18 ms | 2272 KB | Output is correct |
24 | Correct | 18 ms | 2272 KB | Output is correct |