# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
785118 | 2023-07-17T05:31:15 Z | Alkarat | Stove (JOI18_stove) | C++14 | 48 ms | 900 KB |
#include <bits/stdc++.h> using namespace std; int n,k,x; long long ans; priority_queue<int,vector<int>,greater<int>>pq; int main() { cin>>n>>k>>x; int l=x,r=x+1; for(int i=2; i<=n; i++) { cin>>x; if(x==r) r=x+1; else { pq.push(x-r); ans+=r-l; l=x,r=x+1; } } ans+=r-l; while(pq.size()>=k) { ans+=pq.top(); pq.pop(); } cout<<ans; }
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 | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 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 | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 2 ms | 212 KB | Output is correct |
11 | Correct | 2 ms | 212 KB | Output is correct |
12 | Correct | 2 ms | 212 KB | Output is correct |
13 | Correct | 2 ms | 212 KB | Output is correct |
14 | Correct | 2 ms | 212 KB | Output is correct |
15 | Correct | 2 ms | 328 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 | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 2 ms | 212 KB | Output is correct |
11 | Correct | 2 ms | 212 KB | Output is correct |
12 | Correct | 2 ms | 212 KB | Output is correct |
13 | Correct | 2 ms | 212 KB | Output is correct |
14 | Correct | 2 ms | 212 KB | Output is correct |
15 | Correct | 2 ms | 328 KB | Output is correct |
16 | Correct | 43 ms | 848 KB | Output is correct |
17 | Correct | 43 ms | 864 KB | Output is correct |
18 | Correct | 48 ms | 848 KB | Output is correct |
19 | Correct | 44 ms | 848 KB | Output is correct |
20 | Correct | 40 ms | 848 KB | Output is correct |
21 | Correct | 36 ms | 880 KB | Output is correct |
22 | Correct | 35 ms | 832 KB | Output is correct |
23 | Correct | 34 ms | 848 KB | Output is correct |
24 | Correct | 39 ms | 900 KB | Output is correct |