Submission #1053574

#TimeUsernameProblemLanguageResultExecution timeMemory
1053574NAMINStove (JOI18_stove)C++14
100 / 100
17 ms2464 KiB
/* ID: NAMIN TASK: LANG: C++ */ #include <iostream> #include <numeric> #include <math.h> #include <set> #include <vector> #include <string> #include <algorithm> #include <math.h> #include <queue> #include <fstream> #include <map> #include <unordered_map> #include <iomanip> #define gcd __gcd #define endl "\n" #define ll long long using namespace std; void solve(){ ios::sync_with_stdio(false); cin.tie(0); int n,k; cin >> n >> k; vector<int> visit(n); for(int i=0;i<n;i++) cin >> visit[i]; sort(visit.begin(),visit.end()); int T = visit[n-1]-visit[0]+1; priority_queue<int> q; for(int i=0;i<n-1;i++){ q.push(visit[i+1]-visit[i]-1); } for(int i=0;i<k-1;i++){ T -= q.top(); q.pop(); } cout << T << endl; } int main(){ int t = 1; while(t--){ solve(); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...