제출 #1292444

#제출 시각아이디문제언어결과실행 시간메모리
1292444olympolympStove (JOI18_stove)C++20
100 / 100
14 ms1488 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int cimbom, gs; cin >> cimbom >> gs; vector<int> bjk(cimbom); for (int i = 0; i < cimbom; i++) { cin >> bjk[i]; } long long ist = bjk[cimbom - 1] - bjk[0] + 1; vector<int> ts; for (int i = 0; i < cimbom - 1; i++) { ts.push_back(bjk[i + 1] - bjk[i] - 1); } sort(ts.rbegin(), ts.rend()); for (int i = 0; i < gs - 1 && i < ts.size(); i++) { ist -= ts[i]; } cout << ist << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...