Submission #52614

# Submission time Handle Problem Language Result Execution time Memory
52614 2018-06-26T09:04:37 Z snat123 Stove (JOI18_stove) C++14
100 / 100
30 ms 11024 KB
#include<bits/stdc++.h>
 
using namespace std;
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, k, res=0, cnt;
    cin >> n >> k;
    if(k==n){
    	cout << n; 
    	return 0;
    }
    res=n;
    cnt=n;
    long long a[n];
    for(int i=0; i<n; i++) cin >> a[i];
    vector<int>v;
    for(int i=1; i<n; i++){
    	v.push_back(a[i]-a[i-1]-1);
    }
    sort(v.begin(), v.end());
    for(int i=0; i<v.size(); i++){
    	res+=v[i];
    	cnt--;
    	if(cnt==k) break;
    }
    cout << res;
    return 0;
} 

Compilation message

stove.cpp: In function 'int main()':
stove.cpp:23:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0; i<v.size(); i++){
                  ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 460 KB Output is correct
3 Correct 3 ms 468 KB Output is correct
4 Correct 3 ms 584 KB Output is correct
5 Correct 4 ms 768 KB Output is correct
6 Correct 3 ms 768 KB Output is correct
7 Correct 2 ms 768 KB Output is correct
8 Correct 2 ms 768 KB Output is correct
9 Correct 2 ms 768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 460 KB Output is correct
3 Correct 3 ms 468 KB Output is correct
4 Correct 3 ms 584 KB Output is correct
5 Correct 4 ms 768 KB Output is correct
6 Correct 3 ms 768 KB Output is correct
7 Correct 2 ms 768 KB Output is correct
8 Correct 2 ms 768 KB Output is correct
9 Correct 2 ms 768 KB Output is correct
10 Correct 3 ms 836 KB Output is correct
11 Correct 2 ms 972 KB Output is correct
12 Correct 3 ms 972 KB Output is correct
13 Correct 3 ms 972 KB Output is correct
14 Correct 3 ms 972 KB Output is correct
15 Correct 3 ms 972 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 460 KB Output is correct
3 Correct 3 ms 468 KB Output is correct
4 Correct 3 ms 584 KB Output is correct
5 Correct 4 ms 768 KB Output is correct
6 Correct 3 ms 768 KB Output is correct
7 Correct 2 ms 768 KB Output is correct
8 Correct 2 ms 768 KB Output is correct
9 Correct 2 ms 768 KB Output is correct
10 Correct 3 ms 836 KB Output is correct
11 Correct 2 ms 972 KB Output is correct
12 Correct 3 ms 972 KB Output is correct
13 Correct 3 ms 972 KB Output is correct
14 Correct 3 ms 972 KB Output is correct
15 Correct 3 ms 972 KB Output is correct
16 Correct 24 ms 3280 KB Output is correct
17 Correct 26 ms 4244 KB Output is correct
18 Correct 25 ms 5224 KB Output is correct
19 Correct 26 ms 6188 KB Output is correct
20 Correct 24 ms 7152 KB Output is correct
21 Correct 25 ms 8116 KB Output is correct
22 Correct 30 ms 9096 KB Output is correct
23 Correct 27 ms 10072 KB Output is correct
24 Correct 24 ms 11024 KB Output is correct