제출 #1252611

#제출 시각아이디문제언어결과실행 시간메모리
1252611pvb.tunglamStove (JOI18_stove)C++20
100 / 100
11 ms1864 KiB
#include <bits/stdc++.h> #define hash _hash_ #define y1 _y1_ #define left _left_ #define right _right_ #define dec _dec_ #define int long long using namespace std; using ll = long long; using ull = unsigned long long; /*----------- I alone decide my fate! ------------*/ /* I just do what I gotta, in the heat of the summer... */ int N, K, a[100009], d[100009]; void solve() { cin >> N >> K; for (int i = 1; i <= N; i ++) { cin >> a[i]; } for (int i = 2; i <= N; i ++) { d[i - 1] = a[i] - a[i - 1] - 1; } sort(d + 1, d + N, greater <int> ()); ll res = a[N] - a[1] + 1; for (int i = 1; i < K; i ++) { res -= d[i]; } cout << res; } signed main() { ios_base::sync_with_stdio(0); cin.tie(nullptr); solve(); } /* How can you see into my eyes, like open doors? Leading you down into my core, where I've become so numb Without a soul, my spirit's sleeping somewhere cold Until you find it here and bring it back home! Wake me up! Wake me up inside Cant wake up? Wake me up inside */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...