답안 #126350

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
126350 2019-07-07T12:38:07 Z EntityIT Stove (JOI18_stove) C++14
100 / 100
28 ms 2088 KB
#include<bits/stdc++.h>

using namespace std;

const int N = (int)1e5 + 5;
int n, K, a[N], dist[N], ans;

int main () {
    scanf("%d %d", &n, &K);
    for (int i = 0; i < n; ++i) scanf("%d", a + i);
    for (int i = 1; i < n; ++i) dist[i] = a[i] - a[i - 1] - 1;
    sort(dist + 1, dist + n);

    ans = n;
    for (int i = 1; i <= n - K; ++i) ans += dist[i];

    printf("%d", ans);

    return 0;
}

Compilation message

stove.cpp: In function 'int main()':
stove.cpp:9: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:10:38: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for (int i = 0; i < n; ++i) scanf("%d", a + i);
                                 ~~~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 252 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 252 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 3 ms 376 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 3 ms 376 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 252 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 3 ms 376 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 3 ms 376 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 28 ms 2088 KB Output is correct
17 Correct 26 ms 2040 KB Output is correct
18 Correct 26 ms 2040 KB Output is correct
19 Correct 26 ms 2056 KB Output is correct
20 Correct 26 ms 2040 KB Output is correct
21 Correct 26 ms 2040 KB Output is correct
22 Correct 26 ms 2040 KB Output is correct
23 Correct 26 ms 2052 KB Output is correct
24 Correct 26 ms 2040 KB Output is correct