답안 #111915

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
111915 2019-05-16T19:03:19 Z dolphingarlic Stove (JOI18_stove) C++14
0 / 100
3 ms 384 KB
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define FOR(i, x, y) for(int i = x; i < y; i++)
typedef long long ll;
using namespace std;

ll diffs[100001];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, k;
    cin >> n >> k;
    ll mx, mn, curr;
    cin >> mn;
    curr = mn;
    FOR(i, 0, n - 1) {
        cin >> mx;
        diffs[i] = mx - curr;
        curr = mx;
    }
    sort(diffs, diffs + n - 1, greater<ll>());
    ll ans = mx - mn;
    FOR(i, 0, k - 1) ans -= diffs[i];
    cout << ans + k << '\n';
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Incorrect 2 ms 384 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Incorrect 2 ms 384 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Incorrect 2 ms 384 KB Output isn't correct