답안 #545425

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
545425 2022-04-04T13:33:28 Z LunaMeme Stove (JOI18_stove) C++14
0 / 100
1 ms 212 KB
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> ii;
typedef vector<pair<int, int>> vii;
typedef vector<int> vi;
typedef long long ll;
#define PB push_back
#define MP make_pair
#define FOR(i, x, y) for (int i = x; i < y ; i ++)

int main(){
    int n, k; cin >> n >> k;
    int prev;
    vi gaps;
    cin >> prev;
    FOR(i, 0, n - 1){
        int num; cin >> num;
        gaps.PB(num - prev - 1);
        prev = num;
    }
    sort(gaps.begin(), gaps.end());
    ll ans = n;
    FOR(i, 0, k - 1){
        ans += gaps[i];
    }
    cout << ans << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -