제출 #880186

#제출 시각아이디문제언어결과실행 시간메모리
880186niterStove (JOI18_stove)C++14
100 / 100
35 ms1596 KiB
#include <bits/stdc++.h> #define loop(i,a,b) for(int i = (a); i < (b); i ++) #define pb push_back #define ins insert #define pii pair<int,int> #define ff first #define ss second #define op(x) cerr << #x << " = " << x << endl; #define opa(x) cerr << #x << " = " << x << ", "; #define ops(x) cerr << x; #define entr cerr << endl; #define spac cerr << ' '; #define STL(x) cerr << #x << " : "; for(auto &qwe:x) cerr << qwe << ' '; cerr << endl; #define ARR(x, nnn) cerr << #x << " : "; loop(qwe,0,nnn) cerr << x[qwe] << ' '; cerr << endl; #define BAE(x) x.begin(), x.end() #define unilize(x) x.resize(unique(BAE(x)) - x.begin()) #define unisort(x) sort(BAE(x)); unilize(x); using namespace std; const int mxn = (int)(1e5) + 10; int a[mxn]; int main(){ int n, k; cin >> n >> k; int ans = n; loop(i,0,n){ cin >> a[i]; } vector<int> v; loop(i,1,n){ v.pb(a[i] - a[i-1] - 1); } sort(BAE(v)); int take = n - k; loop(i,0,take){ ans += v[i]; } cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...