제출 #735374

#제출 시각아이디문제언어결과실행 시간메모리
735374That_SalamanderStove (JOI18_stove)C++17
100 / 100
23 ms2832 KiB
#include <bits/stdc++.h> #define int long long #define FOR(var,bound) for(int var = 0; var < bound; var++) #define FORB(var,lb,ub) for (int var = lb; var < ub; var++) #define FORR(var,bound) for(int var = bound-1; var >= 0; var--) using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<vector<int>> vvi; typedef pair<int, int> pii; int n, k; int t[100005]; int ds[100005]; signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n >> k; FOR (i, n) { cin >> t[i]; } FOR (i, n - 1) { ds[i] = t[i+1] - t[i] - 1; } sort(ds, ds + n - 1); int res = t[n - 1] - t[0] + 1; FOR (i, k - 1) { res -= ds[n - 2 - i]; } cout << res << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...