Submission #678045

# Submission time Handle Problem Language Result Execution time Memory
678045 2023-01-05T05:13:14 Z vjudge1 Stove (JOI18_stove) C++
0 / 100
1 ms 980 KB
#include <bits/stdc++.h>
using namespace std;
deque <int> d;
int main(){
    long long 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 1 ms 980 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 980 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 980 KB Output isn't correct
2 Halted 0 ms 0 KB -