제출 #1292942

#제출 시각아이디문제언어결과실행 시간메모리
1292942olympolympStove (JOI18_stove)C++20
100 / 100
17 ms2360 KiB
#include <bits/stdc++.h> #define int long long #define all(x) x.begin(), x.end() using namespace std; signed main() { int cimbom, gs; if (scanf("%lld %lld", &cimbom, &gs) != 2) return 0; vector<int> bjk(cimbom); for (int i = 0; i < cimbom; i++) { if (scanf("%lld", &bjk[i]) != 1) return 0; } int 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]; } printf("%lld\n", ist); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...