답안 #703360

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
703360 2023-02-27T07:11:46 Z 1075508020060209tc Stove (JOI18_stove) C++14
100 / 100
50 ms 3192 KB
//#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define X first
#define Y second
int n;int k;
int ar[500005];
signed main(){

cin>>n>>k;
for(int i=1;i<=n;i++){
    cin>>ar[i];
}
int ans=n;
priority_queue<int,vector<int>,greater<int>>pq;
for(int i=2;i<=n;i++){
    pq.push(ar[i]-ar[i-1]-1);
}
for(int i=1;i<=n-k;i++){
    ans+=pq.top();
    pq.pop();

}cout<<ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 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 312 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 308 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 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 312 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 308 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 2 ms 344 KB Output is correct
11 Correct 2 ms 340 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 2 ms 448 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 2 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 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 312 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 308 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 2 ms 344 KB Output is correct
11 Correct 2 ms 340 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 2 ms 448 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 2 ms 344 KB Output is correct
16 Correct 50 ms 3184 KB Output is correct
17 Correct 48 ms 3144 KB Output is correct
18 Correct 48 ms 3124 KB Output is correct
19 Correct 50 ms 3156 KB Output is correct
20 Correct 47 ms 3172 KB Output is correct
21 Correct 40 ms 3092 KB Output is correct
22 Correct 47 ms 3192 KB Output is correct
23 Correct 37 ms 3160 KB Output is correct
24 Correct 38 ms 3144 KB Output is correct