Submission #229502

#TimeUsernameProblemLanguageResultExecution timeMemory
229502hanagasumiStove (JOI18_stove)C++17
100 / 100
28 ms2428 KiB
#include <iostream> #include <vector> #include <cmath> #include <algorithm> #include <deque> #include <map> #include <set> #include <complex> #include <string> #include <unordered_map> #include <unordered_set> #include <random> #define ft first #define sc second #define pb push_back #define len(v) (int)v.size() #define int ll using namespace std; typedef long long ll; signed main() { #ifdef PC freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout); #endif ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, k, ans, pr = -1; cin >> n >> k; ans = n; vector<int> can; for (int i = 0; i < n; i++) { int t; cin >> t; if(i > 0) can.pb(t - pr); pr = t + 1; } sort(can.begin(), can.end()); for (int i = 0; i < (n - k); i++) ans += can[i]; cout << ans << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...