Submission #678043

# Submission time Handle Problem Language Result Execution time Memory
678043 2023-01-05T05:10:18 Z vjudge1 Stove (JOI18_stove) C++
0 / 100
0 ms 596 KB
#include <bits/stdc++.h>
using namespace std;
deque <int> d;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n , k, a[100005], ans=0;
    cin >> n >> k;
    
    if(k==1){
        cout<<n;
        return 0;
    }
    for(int i=1; i<=n; i++){
        cin >> a[i];
    }
    
    ans=a[1]-1;
    
    for(int i=2; i<n; i++){
        d.push_back(a[i]-a[i-1]);
    }
    
    sort(d.begin(), d.end());
    
    for(int i=0; i<k; i++){
        ans+=d[i];
    }
    cout<<a[n] - ans;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 596 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 596 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 596 KB Output isn't correct
2 Halted 0 ms 0 KB -