# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1113284 | hpesoj | Stove (JOI18_stove) | C++17 | 26 ms | 3388 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define int long long
#define pi pair<int, int>
#define ppi pair<pi, int>
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define mp make_pair
#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << ": " << x << '\n'
#define debug2(x, y) cout << #x << ": " << x << ' ' << #y << ": " << y << '\n'
#define debug3(x, y, z) cout << #x << ": " << x << ' ' << #y << ": " << y << ' ' << #z << ": " << z << '\n'
using namespace std;
mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());
const int inf = 1e18+5, mod = 1000000007;
signed main(){
ios::sync_with_stdio(0), cin.tie(0);
int n, k; cin >> n >> k;
int t[n+1];
for(int i = 1; i <= n; i++) cin >> t[i];
int ans = n;
priority_queue <int, vector <int>, greater <int>> pq;
for(int i = 2; i <= n; i++) if(t[i] - t[i-1] > 1) pq.push(t[i] - t[i-1] - 1);
while(pq.size() >= k) ans += pq.top(), pq.pop();
cout << ans;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |