Submission #48827

# Submission time Handle Problem Language Result Execution time Memory
48827 2018-05-19T08:14:50 Z faishol27 Stove (JOI18_stove) C++14
0 / 100
3 ms 376 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define PUB push_back

int N, K;
ll data[100005], ans = 0;
vector<ll>selisih;

int main(){
    cin >> N >> K;
    for(int i=0;i<N;i++) cin >> data[i];
    
    for(int i=0;i<N-1;i++){
        selisih.PUB(data[i+1]-(data[i]+1));
        ans += selisih[i];
    }
    
    ans += N;

    sort(selisih.begin(), selisih.end());

    for(int i=1;i<=K;i++){
        ans -= selisih[N-1-i];
    }

    cout << ans << endl;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -