답안 #229553

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
229553 2020-05-05T04:54:29 Z JodsintZ Stove (JOI18_stove) C++14
100 / 100
35 ms 2544 KB
#include <bits/stdc++.h>

#define long long long

using namespace std;

vector<int> v, d;
int n, k, ans;

int main() {
    scanf("%d %d", &n, &k);
    for(int i = 0, t; i < n; i++) {
        scanf("%d", &t);
        v.emplace_back(t);
    }
    for(int i = 1; i < n; i++) {
        d.emplace_back(v[i] - v[i-1] - 1);
    }
    sort(d.begin(), d.end(), greater<int>());
    ans = v.back() - v[0] + 1;
    for(int i = 0; i < k-1; i++) {
        ans -= d[i];
    }
    printf("%d\n", ans);
    return 0;
}

Compilation message

stove.cpp: In function 'int main()':
stove.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &n, &k);
     ~~~~~^~~~~~~~~~~~~~~~~
stove.cpp:13:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &t);
         ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 4 ms 256 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 4 ms 256 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 4 ms 256 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 4 ms 256 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 6 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 4 ms 256 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 4 ms 256 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 6 ms 384 KB Output is correct
16 Correct 33 ms 2544 KB Output is correct
17 Correct 31 ms 2424 KB Output is correct
18 Correct 32 ms 2424 KB Output is correct
19 Correct 31 ms 2424 KB Output is correct
20 Correct 31 ms 2424 KB Output is correct
21 Correct 31 ms 2424 KB Output is correct
22 Correct 32 ms 2416 KB Output is correct
23 Correct 35 ms 2424 KB Output is correct
24 Correct 33 ms 2416 KB Output is correct