제출 #969498

#제출 시각아이디문제언어결과실행 시간메모리
969498crazycoder00Stove (JOI18_stove)C++17
100 / 100
17 ms2468 KiB
#include <bits/stdc++.h> using namespace std; // Templates // ============================================== // Debugging #ifdef LOCAL #include "debug.h" #else #define debug(...) #endif typedef long long ll; typedef vector<int> VI; typedef vector<long long> VLL; typedef vector<bool> VB; typedef vector<vector<int>> VVI; typedef pair<int, int> PI; typedef pair<ll, ll> PLL; typedef vector<pair<int, int>> VPI; #define pb push_back #define ff first #define ss second #define loop(i, s, e) for (int i = s; i < e; ++i) #define inp(v) for (auto& x : v) cin >> x #define all(a) a.begin(), a.end() #define revall(a) a.rbegin(), a.rend() #define nl "\n" // #define MOD 998244353 #define MOD 1000000007 #define MAXN 300002 #define INF (int) 1e9 #define INFL (ll) 1e18 #define yep cout << "YES\n" #define nope cout << "NO\n" // ============================================== void solve() { int n, k; cin >> n >> k; VI a(n); inp(a); VI interval; loop(i, 1, n) interval.pb(a[i] - a[i - 1] - 1); sort(revall(interval)); int ans = a[n - 1] - a[0] + 1; loop(i, 0, k - 1) ans -= interval[i]; cout << ans << nl; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int t = 1; // cin >> t; while(t--) solve(); #ifdef LOCAL cerr << "Execution time: " << 1000.f * clock() / CLOCKS_PER_SEC << " ms." << nl; #endif return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...