답안 #541671

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
541671 2022-03-24T06:44:19 Z AngusWong Stove (JOI18_stove) C++17
100 / 100
53 ms 1280 KB
#include <bits/stdc++.h>
#define pii pair<int, int>
#define f first
#define s second
using namespace std;

int n, k, a[100001], ans;
vector<int> v;

int main(){
    cin >> n >> k;
    for (int i=1; i<=n; i++){
        cin >> a[i];
        if (i>1) v.push_back(a[i]-a[i-1]-1);
    }
    sort(v.begin(), v.end());
    ans=n;
    for (int i=0; i<n-k; i++) ans+=v[i];
    cout << ans << "\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 232 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 232 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 3 ms 340 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 232 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 3 ms 340 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
16 Correct 49 ms 1280 KB Output is correct
17 Correct 47 ms 1160 KB Output is correct
18 Correct 44 ms 1084 KB Output is correct
19 Correct 50 ms 1096 KB Output is correct
20 Correct 51 ms 1184 KB Output is correct
21 Correct 47 ms 1104 KB Output is correct
22 Correct 53 ms 1160 KB Output is correct
23 Correct 48 ms 1156 KB Output is correct
24 Correct 46 ms 1144 KB Output is correct