Submission #638916

#TimeUsernameProblemLanguageResultExecution timeMemory
638916rc_catuntaStove (JOI18_stove)C++14
100 / 100
34 ms3388 KiB
#include <bits/stdc++.h> using namespace std; typedef vector<int> vi; typedef pair<int,int> ii; typedef vector<ii> vii; int main(){ ios_base::sync_with_stdio(false); int N,K,x; vi guests; vector< ii > te; cin>>N>>K; for(int i=0;i<N;i++){ cin>>x; guests.push_back(x); } // Tiempos de Espera for(int i=0;i<N-1;i++){ te.push_back(ii(guests[i+1]-guests[i],i+1)); } sort(te.rbegin(),te.rend()); vi posiciones; for(int i=0;i<K-1;i++){ posiciones.push_back(te[i].second); } sort(posiciones.begin(),posiciones.end()); int pos_anterior = 0; int tiempo = 0; for(auto p: posiciones){ tiempo += guests[p-1]-guests[pos_anterior]+1; pos_anterior = p; } tiempo += guests[N-1]-guests[pos_anterior]+1; cout<<tiempo<<"\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...