제출 #1002215

#제출 시각아이디문제언어결과실행 시간메모리
1002215zh_hStove (JOI18_stove)C++17
100 / 100
16 ms2592 KiB
#include <bits/stdc++.h> #define lint long long #define pb push_back #define mp make_pair using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, k; cin >> n >> k; vector<int> v; for(int i = 0; i < n; i ++){ int temp; cin >> temp; v.pb(temp); } vector<int> vb; for(int i = 1; i < n; i ++){ vb.pb(v[i]-v[i-1]-1); } sort(vb.begin(), vb.end()); // for(auto i : vb){cout << i << " ";} cout << endl; int time = n; if(k >= n){cout << n;} else{ for(int i = 0; i < n-k; i ++){ time+=vb[i]; } cout << time; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...