답안 #1033573

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1033573 2024-07-25T04:02:43 Z quannnguyen2009 Stove (JOI18_stove) C++14
0 / 100
1 ms 348 KB
#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define pb push_back
#define ii pair<int, int>
#define sz(v) (int)v.size()
#define all(v) v.begin(), v.end()
using namespace std;

const int N=1e5+5, mod = 1e9+7, inf = 1e18;

int n, k;
int a[N];

signed main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> k;
    for (int i=1; i<=n; i++) cin >> a[i];
    vector<int> b;
    for (int i=2; i<=n; i++) {
        b.pb(a[i]-a[i-1]-1);
    }
    sort(all(b), greater<int>());
    int cnt = 0;
    for (int i=0; i<k-1; i++) cnt += b[i];
    cout << a[n]-cnt;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 1 ms 344 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 1 ms 344 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 1 ms 344 KB Output isn't correct
3 Halted 0 ms 0 KB -