제출 #994550

#제출 시각아이디문제언어결과실행 시간메모리
994550APROHACKStove (JOI18_stove)C++17
100 / 100
16 ms2432 KiB
#include <bits/stdc++.h> #define ll long long #define ff first #define ss second #define pb push_back using namespace std; ll n, k; vector<int>t; vector<int>restas; void tc(){ cin >> n >> k; for(int i = 0 ; i < n ; i ++){ int temp; cin >> temp; if(i > 0)restas.pb(temp - t.back() - 1); t.pb(temp); } sort(restas.begin(), restas.end()); int total = t.back() + 1 - t[0]; for(int i = 0 ; i < k - 1 ; i ++){ if(!restas.empty()){ total -= restas.back(); restas.pop_back(); } } cout << total << "\n"; } void end_tc(){ } int main() { cin.tie(0); cout.tie(0); ios::sync_with_stdio(NULL); int t = 1; while(t--){ tc(); end_tc(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...