Submission #171149

# Submission time Handle Problem Language Result Execution time Memory
171149 2019-12-27T13:51:24 Z Nodir_Bobiev Stove (JOI18_stove) C++14
100 / 100
41 ms 2608 KB
# include <bits/stdc++.h>
# define FILE
using namespace std;

int main(){

    # ifdef FILEs
        freopen( "input.txt", "r", stdin );
        freopen( "output.txt", "w", stdout );
    # endif
    ios_base::sync_with_stdio( false );
    int n, k;
    cin >> n >> k;
    vector < int > times;
    for( int i = 0; i < n;i ++ ){
    	int tt;
    	cin >> tt;
    	times.push_back( tt );
    }
    int ans = times.back()-times[0]+1;
    vector < int > diff;
    for( int i = 0; i < n-1; i ++ ){
    	diff.push_back( times[i+1]-times[i]-1 );
    }

    sort( diff.rbegin(), diff.rend() );
    for( int i = 0; i < k -1; i ++ )
    	ans -= diff[i];
    cout << ans;

    return 0;
}	

# Verdict Execution time Memory Grader output
1 Correct 4 ms 452 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 4 ms 376 KB Output is correct
4 Correct 3 ms 380 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 4 ms 376 KB Output is correct
8 Correct 1 ms 376 KB Output is correct
9 Correct 3 ms 380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 452 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 4 ms 376 KB Output is correct
4 Correct 3 ms 380 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 4 ms 376 KB Output is correct
8 Correct 1 ms 376 KB Output is correct
9 Correct 3 ms 380 KB Output is correct
10 Correct 3 ms 376 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 4 ms 376 KB Output is correct
13 Correct 4 ms 376 KB Output is correct
14 Correct 5 ms 376 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 452 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 4 ms 376 KB Output is correct
4 Correct 3 ms 380 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 4 ms 376 KB Output is correct
8 Correct 1 ms 376 KB Output is correct
9 Correct 3 ms 380 KB Output is correct
10 Correct 3 ms 376 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 4 ms 376 KB Output is correct
13 Correct 4 ms 376 KB Output is correct
14 Correct 5 ms 376 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 28 ms 2548 KB Output is correct
17 Correct 41 ms 2608 KB Output is correct
18 Correct 32 ms 2516 KB Output is correct
19 Correct 28 ms 2548 KB Output is correct
20 Correct 28 ms 2548 KB Output is correct
21 Correct 29 ms 2548 KB Output is correct
22 Correct 27 ms 2420 KB Output is correct
23 Correct 29 ms 2548 KB Output is correct
24 Correct 27 ms 2548 KB Output is correct