제출 #687678

#제출 시각아이디문제언어결과실행 시간메모리
687678NK_Stove (JOI18_stove)C++17
100 / 100
18 ms1860 KiB
// Success consists of going from failure to failure without loss of enthusiasm #include <bits/stdc++.h> using namespace std; #define nl '\n' int main() { cin.tie(0)->sync_with_stdio(0); int N, K; cin >> N >> K; vector<int> gaps; int t; cin >> t; int ans = -t; for(int i = 1; i < N; i++) { int x; cin >> x; gaps.push_back(x-t-1); t = x; } // for(auto x : gaps) cout << x << " "; sort(rbegin(gaps), rend(gaps)); ans += t+1; for(int i = 0; i < min(K-1, int(size(gaps))); i++) ans -= gaps[i]; cout << ans << nl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...