답안 #437171

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
437171 2021-06-26T01:20:28 Z skyberg Stove (JOI18_stove) C++17
100 / 100
77 ms 2364 KB
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
vector<long long int>d;
bool comp(long long int a,long long int b){
    return a > b;
}
int main() {
    long long int n, k;
    long long int sumd;
    cin >> n >> k;
    long long int a;
    cin >> a;
    sumd = a;
    long long int b = a;
    for(int i = 1; i < n; i++){
        cin >> b;
        d.push_back(b - a - 1);
        a = b;
    }
    sumd = b + 1 - sumd;
    sort(d.begin(), d.end(), comp);
    for(int i = 0; i < min((long long)d.size(),k - 1); i++){
        sumd -= d[i];
    }
    cout << sumd;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 328 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 328 KB Output is correct
10 Correct 3 ms 332 KB Output is correct
11 Correct 3 ms 332 KB Output is correct
12 Correct 2 ms 332 KB Output is correct
13 Correct 3 ms 300 KB Output is correct
14 Correct 2 ms 332 KB Output is correct
15 Correct 2 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 328 KB Output is correct
10 Correct 3 ms 332 KB Output is correct
11 Correct 3 ms 332 KB Output is correct
12 Correct 2 ms 332 KB Output is correct
13 Correct 3 ms 300 KB Output is correct
14 Correct 2 ms 332 KB Output is correct
15 Correct 2 ms 332 KB Output is correct
16 Correct 54 ms 2244 KB Output is correct
17 Correct 55 ms 2364 KB Output is correct
18 Correct 54 ms 2252 KB Output is correct
19 Correct 63 ms 2308 KB Output is correct
20 Correct 55 ms 2204 KB Output is correct
21 Correct 61 ms 2308 KB Output is correct
22 Correct 57 ms 2284 KB Output is correct
23 Correct 77 ms 2200 KB Output is correct
24 Correct 66 ms 2284 KB Output is correct