Submission #71439

# Submission time Handle Problem Language Result Execution time Memory
71439 2018-08-24T16:06:16 Z win11905 Stove (JOI18_stove) C++11
100 / 100
38 ms 10208 KB
#include <bits/stdc++.h>
using namespace std;

int n, k;

int main() {
    scanf("%d %d", &n, &k);
    vector<int> V;
    int pv; scanf("%d", &pv);
    for(int i = 1, a; i < n; ++i) {
        scanf("%d", &a);
        V.emplace_back(a - pv - 1);
        pv = a;
    }
    sort(V.begin(), V.end());
    int v = n-k;
    for(int i = 0; i < v; ++i) n += V[i];
    printf("%d\n", n);
}

Compilation message

stove.cpp: In function 'int main()':
stove.cpp:7: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:9:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     int pv; scanf("%d", &pv);
             ~~~~~^~~~~~~~~~~
stove.cpp:11:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &a);
         ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 3 ms 548 KB Output is correct
4 Correct 2 ms 548 KB Output is correct
5 Correct 2 ms 548 KB Output is correct
6 Correct 3 ms 548 KB Output is correct
7 Correct 2 ms 580 KB Output is correct
8 Correct 3 ms 588 KB Output is correct
9 Correct 2 ms 736 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 3 ms 548 KB Output is correct
4 Correct 2 ms 548 KB Output is correct
5 Correct 2 ms 548 KB Output is correct
6 Correct 3 ms 548 KB Output is correct
7 Correct 2 ms 580 KB Output is correct
8 Correct 3 ms 588 KB Output is correct
9 Correct 2 ms 736 KB Output is correct
10 Correct 5 ms 752 KB Output is correct
11 Correct 4 ms 784 KB Output is correct
12 Correct 4 ms 832 KB Output is correct
13 Correct 3 ms 864 KB Output is correct
14 Correct 4 ms 896 KB Output is correct
15 Correct 4 ms 944 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 3 ms 548 KB Output is correct
4 Correct 2 ms 548 KB Output is correct
5 Correct 2 ms 548 KB Output is correct
6 Correct 3 ms 548 KB Output is correct
7 Correct 2 ms 580 KB Output is correct
8 Correct 3 ms 588 KB Output is correct
9 Correct 2 ms 736 KB Output is correct
10 Correct 5 ms 752 KB Output is correct
11 Correct 4 ms 784 KB Output is correct
12 Correct 4 ms 832 KB Output is correct
13 Correct 3 ms 864 KB Output is correct
14 Correct 4 ms 896 KB Output is correct
15 Correct 4 ms 944 KB Output is correct
16 Correct 32 ms 2380 KB Output is correct
17 Correct 38 ms 3472 KB Output is correct
18 Correct 29 ms 4324 KB Output is correct
19 Correct 28 ms 5288 KB Output is correct
20 Correct 31 ms 6252 KB Output is correct
21 Correct 29 ms 7216 KB Output is correct
22 Correct 35 ms 8308 KB Output is correct
23 Correct 31 ms 9280 KB Output is correct
24 Correct 29 ms 10208 KB Output is correct