Submission #75103

# Submission time Handle Problem Language Result Execution time Memory
75103 2018-09-08T11:00:33 Z bogdan10bos Stove (JOI18_stove) C++14
100 / 100
39 ms 10408 KB
#include <bits/stdc++.h>

using namespace std;

//#define FILE_IO

int N, K;
int v[100005];
int t[100005];

int main()
{
    #ifdef FILE_IO
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
    #endif

    scanf("%d", &N);
    scanf("%d", &K);
    for(int i = 1; i <= N; i++)
        scanf("%d", &v[i]);
    for(int i = 1; i < N; i++)
        t[i] = v[i + 1] - v[i] - 1;
    sort(t + 1, t + N);

    int ans = N;
    for(int i = 1; i <= N - K; i++)
        ans += t[i];

    printf("%d\n", ans);

    return 0;
}

Compilation message

stove.cpp: In function 'int main()':
stove.cpp:18:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &N);
     ~~~~~^~~~~~~~~~
stove.cpp:19:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &K);
     ~~~~~^~~~~~~~~~
stove.cpp:21:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &v[i]);
         ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 416 KB Output is correct
4 Correct 2 ms 516 KB Output is correct
5 Correct 2 ms 752 KB Output is correct
6 Correct 2 ms 752 KB Output is correct
7 Correct 2 ms 752 KB Output is correct
8 Correct 2 ms 752 KB Output is correct
9 Correct 2 ms 784 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 416 KB Output is correct
4 Correct 2 ms 516 KB Output is correct
5 Correct 2 ms 752 KB Output is correct
6 Correct 2 ms 752 KB Output is correct
7 Correct 2 ms 752 KB Output is correct
8 Correct 2 ms 752 KB Output is correct
9 Correct 2 ms 784 KB Output is correct
10 Correct 3 ms 784 KB Output is correct
11 Correct 3 ms 784 KB Output is correct
12 Correct 3 ms 792 KB Output is correct
13 Correct 3 ms 868 KB Output is correct
14 Correct 4 ms 872 KB Output is correct
15 Correct 3 ms 872 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 416 KB Output is correct
4 Correct 2 ms 516 KB Output is correct
5 Correct 2 ms 752 KB Output is correct
6 Correct 2 ms 752 KB Output is correct
7 Correct 2 ms 752 KB Output is correct
8 Correct 2 ms 752 KB Output is correct
9 Correct 2 ms 784 KB Output is correct
10 Correct 3 ms 784 KB Output is correct
11 Correct 3 ms 784 KB Output is correct
12 Correct 3 ms 792 KB Output is correct
13 Correct 3 ms 868 KB Output is correct
14 Correct 4 ms 872 KB Output is correct
15 Correct 3 ms 872 KB Output is correct
16 Correct 32 ms 2744 KB Output is correct
17 Correct 28 ms 3640 KB Output is correct
18 Correct 28 ms 4604 KB Output is correct
19 Correct 28 ms 5696 KB Output is correct
20 Correct 26 ms 6548 KB Output is correct
21 Correct 26 ms 7516 KB Output is correct
22 Correct 26 ms 8476 KB Output is correct
23 Correct 39 ms 9460 KB Output is correct
24 Correct 26 ms 10408 KB Output is correct