제출 #164795

#제출 시각아이디문제언어결과실행 시간메모리
164795cbertramStove (JOI18_stove)C++14
0 / 100
3 ms504 KiB
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; typedef vector<bool> vb; typedef vector<int> vi; typedef vector<ll> vll; typedef vector<pii> vpii; typedef vector<pll> vpll; typedef vector<string> vs; typedef vector<vb> vvb; typedef vector<vi> vvi; typedef vector<vll> vvll; #define all(x) x.begin(), x.end() #define rep(i,a,b) for(int i = a; i < b; i++) int main() { int N, K; cin >> N; cin >> K; vi gs(N); rep(n,0,N) cin >> gs[n]; sort(all(gs)); vi gaps(0); rep(n,0,N-1) { if(gs[n]+1 < gs[n+1]) gaps.push_back(gs[n+1]-gs[n]-1); } sort(all(gaps), greater<>()); int ontime = gs[N-1]-gs[0]+1; rep(k,0,K-1) ontime -= gaps[k]; cout << ontime << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...