제출 #1034835

#제출 시각아이디문제언어결과실행 시간메모리
1034835DeathIsAweStove (JOI18_stove)C++14
0 / 100
1 ms348 KiB
#include <bits/stdc++.h> using namespace std; int main() { int n,k; cin >> n >> k; k--; vector<int> times(n),timediffs; for (int i=0;i<n;i++) { cin >> times[i]; } for (int i=0;i<n-1;i++) { timediffs.push_back(times[i+1]-times[i]); } int ans = times[n-1]; sort(timediffs.begin(),timediffs.end(),greater<int>()); for (int i=0;i<k;i++) { ans -= (timediffs[i]-1); } cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...