Submission #165699

# Submission time Handle Problem Language Result Execution time Memory
165699 2019-11-28T10:43:07 Z Sparky_09 Stove (JOI18_stove) C++17
0 / 100
2 ms 376 KB
#include<bits/stdc++.h>
#ifdef LOCAL_DEFINE
#include<conio.h>
#endif
using namespace std;
void io();
void end();


int main(){
	io();                                     
    int n, k;
    cin>>n>>k;
    vector<int> p, v(n);
    for(int i = 0; i < n; i++){
        cin>>v[i];
        if(i!=0) p.push_back(v[i]-v[i-1]-1);
    }
    sort(p.rbegin(), p.rend());
    int ans = v[n-1];
    for(int i = 0; i < k-1; i++){
        ans-=p[i];
    }
    cout << ans;
	end();
}

void io(){
#ifdef LOCAL_DEFINE
	ios_base::sync_with_stdio(0); cin.tie(0);
	freopen("input.txt", "rt", stdin);
#endif
}

void end(){	
#ifdef LOCAL_DEFINE
	cerr << "\nTime Elapsed: " << 1.0 * clock()/CLOCKS_PER_SEC << " s.\n";
	getch();
#endif
}

# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -