# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
41526 | 2018-02-18T11:51:32 Z | chonka | Stove (JOI18_stove) | C++ | 43 ms | 1804 KB |
#include<iostream> #include<stdio.h> #include<algorithm> using namespace std ; #define MAXN 100007 int n , k ; int a[ MAXN ] ; int b[ MAXN ] ; int ans ; void input ( ) { scanf ( "%d%d" , &n , &k ) ; int i ; for ( i = 1 ; i <= n ; i ++ ) { scanf ( "%d" , &a[ i ] ) ; } ans = n ; } void solve ( ) { int i ; for ( i = 1 ; i < n ; i ++ ) { b[ i ] = ( a[ i + 1 ] - a[ i ] - 1 ) ; } sort ( b + 1 , b + n ) ; for ( i = 1 ; i <= ( n - k ) ; i ++ ) { ans += b[ i ] ; } printf ( "%d\n" , ans ) ; } int main ( ) { input ( ) ; solve ( ) ; return 0 ; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 248 KB | Output is correct |
2 | Correct | 1 ms | 356 KB | Output is correct |
3 | Correct | 2 ms | 560 KB | Output is correct |
4 | Correct | 2 ms | 560 KB | Output is correct |
5 | Correct | 1 ms | 560 KB | Output is correct |
6 | Correct | 2 ms | 560 KB | Output is correct |
7 | Correct | 2 ms | 560 KB | Output is correct |
8 | Correct | 1 ms | 568 KB | Output is correct |
9 | Correct | 2 ms | 580 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 248 KB | Output is correct |
2 | Correct | 1 ms | 356 KB | Output is correct |
3 | Correct | 2 ms | 560 KB | Output is correct |
4 | Correct | 2 ms | 560 KB | Output is correct |
5 | Correct | 1 ms | 560 KB | Output is correct |
6 | Correct | 2 ms | 560 KB | Output is correct |
7 | Correct | 2 ms | 560 KB | Output is correct |
8 | Correct | 1 ms | 568 KB | Output is correct |
9 | Correct | 2 ms | 580 KB | Output is correct |
10 | Correct | 2 ms | 588 KB | Output is correct |
11 | Correct | 2 ms | 664 KB | Output is correct |
12 | Correct | 2 ms | 708 KB | Output is correct |
13 | Correct | 2 ms | 736 KB | Output is correct |
14 | Correct | 2 ms | 788 KB | Output is correct |
15 | Correct | 2 ms | 820 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 248 KB | Output is correct |
2 | Correct | 1 ms | 356 KB | Output is correct |
3 | Correct | 2 ms | 560 KB | Output is correct |
4 | Correct | 2 ms | 560 KB | Output is correct |
5 | Correct | 1 ms | 560 KB | Output is correct |
6 | Correct | 2 ms | 560 KB | Output is correct |
7 | Correct | 2 ms | 560 KB | Output is correct |
8 | Correct | 1 ms | 568 KB | Output is correct |
9 | Correct | 2 ms | 580 KB | Output is correct |
10 | Correct | 2 ms | 588 KB | Output is correct |
11 | Correct | 2 ms | 664 KB | Output is correct |
12 | Correct | 2 ms | 708 KB | Output is correct |
13 | Correct | 2 ms | 736 KB | Output is correct |
14 | Correct | 2 ms | 788 KB | Output is correct |
15 | Correct | 2 ms | 820 KB | Output is correct |
16 | Correct | 25 ms | 1744 KB | Output is correct |
17 | Correct | 29 ms | 1804 KB | Output is correct |
18 | Correct | 30 ms | 1804 KB | Output is correct |
19 | Correct | 25 ms | 1804 KB | Output is correct |
20 | Correct | 28 ms | 1804 KB | Output is correct |
21 | Correct | 26 ms | 1804 KB | Output is correct |
22 | Correct | 43 ms | 1804 KB | Output is correct |
23 | Correct | 26 ms | 1804 KB | Output is correct |
24 | Correct | 25 ms | 1804 KB | Output is correct |