Submission #643495

# Submission time Handle Problem Language Result Execution time Memory
643495 2022-09-22T07:24:07 Z GaLz Stove (JOI18_stove) C++14
100 / 100
27 ms 2272 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
const ll mod=1e9+7;
const ll maxn=1e5+5;
const int INF=1e9;
#define ok ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define endl '\n'
int n, k, arr[maxn], ans;
priority_queue<int> pq;
int main() {
    ok
    cin >> n >> k;
    for(int i=0; i<n; i++) {
        cin >> arr[i];
    }
    ans=arr[n-1]-arr[0]+1;
    for(int i=1; i<n; i++) {
        pq.push(arr[i]-arr[i-1]-1);
    }
    while(!pq.empty()) {
        if(k==1) break;
        ans-=pq.top();
        pq.pop();
        k--;
    }
    cout << ans;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 328 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 328 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 2 ms 364 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 328 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 2 ms 364 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 16 ms 2216 KB Output is correct
17 Correct 12 ms 2272 KB Output is correct
18 Correct 15 ms 2272 KB Output is correct
19 Correct 13 ms 2236 KB Output is correct
20 Correct 17 ms 2264 KB Output is correct
21 Correct 25 ms 2236 KB Output is correct
22 Correct 24 ms 2264 KB Output is correct
23 Correct 27 ms 2236 KB Output is correct
24 Correct 22 ms 2228 KB Output is correct