답안 #1033650

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1033650 2024-07-25T04:09:21 Z coldbr3w Stove (JOI18_stove) C++14
100 / 100
16 ms 2264 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pll pair<long long, long long>
#define pb push_back
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
 
const ll N = 2e5 + 100;
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll block = 480;
ll n,k;
ll a[N];
void to_thic_cau(){
    cin >> n >> k;  
    vector<ll>v;
    for(int i = 1; i <= n;i++){
        cin >> a[i];
        if(i >= 2) v.pb(a[i] - a[i-1] - 1);
    }
    ll s = a[n] - a[1] + 1;
    sort(all(v));
    k--;
    while(v.size() > 0 && k > 0){
        s -= v.back(); v.pop_back();
        k--;
    }
    cout << s << '\n';
}
 
signed main(){

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll tc = 1;
    //cin >> tc;
    while(tc--) to_thic_cau();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 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 1 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 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 1 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 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 1 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 11 ms 2012 KB Output is correct
17 Correct 15 ms 2020 KB Output is correct
18 Correct 13 ms 2264 KB Output is correct
19 Correct 14 ms 2012 KB Output is correct
20 Correct 13 ms 1964 KB Output is correct
21 Correct 12 ms 2008 KB Output is correct
22 Correct 13 ms 2112 KB Output is correct
23 Correct 16 ms 2008 KB Output is correct
24 Correct 11 ms 2012 KB Output is correct