답안 #375179

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
375179 2021-03-09T04:02:58 Z Edbert2397 Stove (JOI18_stove) C++14
100 / 100
27 ms 2284 KB
/*
~2021~
*/
# include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
typedef long long ll;
#define pii pair<int,int>
const int N = 2e5 + 5;
const int INF = 1e9;
const ll mod = 1e9+7;
priority_queue<int>pq;
int n,k,arr[N];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    //freopen(,r,stdin);
    //freopen(,w,stdout);
    cin>>n>>k;
    for(int i = 1;i<=n;i++){
        cin>>arr[i];
        if(i > 1)pq.push(arr[i] - arr[i-1] - 1);
    }
    int ans = arr[n] - arr[1] + 1;
    for(int i = 1;i<=k-1;i++){
        ans -= pq.top();
        pq.pop();
    }
    cout<<ans<<endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 492 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 492 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 15 ms 2284 KB Output is correct
17 Correct 15 ms 2284 KB Output is correct
18 Correct 15 ms 2284 KB Output is correct
19 Correct 16 ms 2284 KB Output is correct
20 Correct 21 ms 2284 KB Output is correct
21 Correct 26 ms 2284 KB Output is correct
22 Correct 26 ms 2284 KB Output is correct
23 Correct 27 ms 2284 KB Output is correct
24 Correct 27 ms 2284 KB Output is correct