제출 #1228754

#제출 시각아이디문제언어결과실행 시간메모리
1228754haiduongStove (JOI18_stove)C++20
0 / 100
0 ms324 KiB
#include<bits/stdc++.h> using namespace std; #define int long long const int N = 2e5 + 10; int t[N]; signed main() { cin.tie(0)->sync_with_stdio(false); int n, k; cin >> n >> k; for(int i = 1; i <= n; i++) { cin >> t[i]; } sort(t + 1, t + n + 1); // sort nếu chưa đảm bảo vector<int> gaps; for(int i = 1; i < n; i++) { int gap = t[i + 1] - (t[i] + 1); if(gap > 0) gaps.push_back(gap); } // tổng thời gian tối thiểu nếu bật riêng từng khách int total_time = n; // cần ghép lại N - K đoạn → chọn N - K khoảng trống nhỏ nhất sort(gaps.begin(), gaps.end()); for(int i = 0; i < n - k && i < (int)gaps.size(); i++) { total_time += gaps[i]; } cout << total_time << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...