Submission #295769

# Submission time Handle Problem Language Result Execution time Memory
295769 2020-09-09T22:46:26 Z aZvezda Stove (JOI18_stove) C++14
100 / 100
100 ms 2452 KB
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#define endl "\n"
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template<class T, class T2> inline bool chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }
template<class T, class T2> inline bool chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }
const ll mod = 1e9 + 7;
template<class T> inline void fix(T &x) {if(x >= mod | x <= -mod) {x %= mod;} if(x < 0) {x += mod;}}
#define out(x) cout << __LINE__ << ": " << (#x) << " = " << (x) << endl

signed main() {
    //ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll last = -1;
    ll n, k;
    cin >> n >> k;
    if(n == 1) {
        cout << 1 << endl;
        return 0;
    }
    ll total = n;
    priority_queue<ll> pq;
    for(ll i = 0; i < n; i ++) {
        ll t;
        //cout << "Input";
        cin >> t;
        if(i != 0) {
            pq.push(last - t + 1);
        }
        last = t;
    }
    //cout << "!!" << last << " " << total << " " << total + last + 1 << endl;
    while(n - k > 0 && !pq.empty()) {
        //cout << "Wtf" << pq.top() << endl;
        total -= pq.top();
        pq.pop();
        k ++;
    }
    cout << total << endl;
    return 0;
}


# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 0 ms 256 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 0 ms 256 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 0 ms 256 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 100 ms 2452 KB Output is correct
17 Correct 100 ms 2416 KB Output is correct
18 Correct 100 ms 2412 KB Output is correct
19 Correct 99 ms 2416 KB Output is correct
20 Correct 92 ms 2416 KB Output is correct
21 Correct 89 ms 2416 KB Output is correct
22 Correct 88 ms 2416 KB Output is correct
23 Correct 86 ms 2416 KB Output is correct
24 Correct 100 ms 2416 KB Output is correct