제출 #1250180

#제출 시각아이디문제언어결과실행 시간메모리
1250180khoavn2008Stove (JOI18_stove)C++20
100 / 100
12 ms2244 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define el '\n' #define fi first #define se second #define pb push_back #define FOR(i,l,r) for(ll i=(l),_r=(r);i<=_r;i++) #define FORNG(i,r,l) for(ll i=(r),_l=(l);i>=_l;i--) #define MASK(i) (1LL<<(i)) #define BIT(x,i) (((x)>>(i))&1LL) #define all(v) (v).begin(),(v).end() #define sz(v) ((ll)(v).size()) const ll mod = 0 ; const ll maxn = 1e6+5 ; ll a[maxn]; int main() { ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); //freopen(".inp", "r", stdin); //freopen(".out", "w", stdout); ll n,k; cin>>n>>k; for (int i=1 ; i<=n; i++) { cin>>a[i]; } vector <ll> b; for (int i=1 ; i<n; i++) { b.pb(a[i+1]- a[i]-1); } sort ( all (b)); ll res=0; for (int i=0 ; i<n-k ; i++) { // cout<<b[i]<< " "; res+= b[i]; } cout<<n+res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...