Submission #153341

# Submission time Handle Problem Language Result Execution time Memory
153341 2019-09-13T13:37:33 Z mhy908 Stove (JOI18_stove) C++14
100 / 100
27 ms 2172 KB
#include <bits/stdc++.h>
int n, k, t[100010], arr[100010], ans;
int main()
{
    scanf("%d %d", &n, &k);
    for(int i=1; i<=n; i++)scanf("%d", &t[i]);
    for(int i=2; i<=n; i++)arr[i-1]=t[i]-t[i-1]-1;
    std::sort(arr+1, arr+n);
    ans=t[n]-t[1]+1;
    for(int i=n-1; i>=n-k+1; i--)ans-=arr[i];
    printf("%d", ans);
}

Compilation message

stove.cpp: In function 'int main()':
stove.cpp:5: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:6:33: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i=1; i<=n; i++)scanf("%d", &t[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 256 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 256 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 376 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 256 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 256 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 376 KB Output is correct
10 Correct 3 ms 380 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
# 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 256 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 256 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 376 KB Output is correct
10 Correct 3 ms 380 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 27 ms 2040 KB Output is correct
17 Correct 27 ms 2040 KB Output is correct
18 Correct 27 ms 2052 KB Output is correct
19 Correct 27 ms 2040 KB Output is correct
20 Correct 27 ms 2172 KB Output is correct
21 Correct 27 ms 2168 KB Output is correct
22 Correct 27 ms 2168 KB Output is correct
23 Correct 27 ms 2040 KB Output is correct
24 Correct 27 ms 2040 KB Output is correct