Submission #339677

# Submission time Handle Problem Language Result Execution time Memory
339677 2020-12-25T20:43:02 Z ijxjdjd Stove (JOI18_stove) C++14
100 / 100
50 ms 2032 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef string str;
typedef double db;
typedef long double ld;

typedef pair<int, int> pi;
typedef  pair<ll, ll> pl;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pi> vpi;


#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define FR(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define RF(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> split;
    int last;
    cin >> last;
    int first = last;
    FR(i, N-1) {
        int next;
        cin >> next;
        if (next - last > 1) {
            split.push_back(next-(last+1));
        }
        last = next;
    }
    int rem = 0;
    sort(split.begin(), split.end());
    for (int k = 1; k <= min(K-1, int(split.size())); k++) {
        rem += split[split.size()-k];
    }
    cout << (last + 1 - first - rem);
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 0 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 0 ms 364 KB Output is correct
10 Correct 2 ms 364 KB Output is correct
11 Correct 2 ms 364 KB Output is correct
12 Correct 2 ms 364 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 364 KB Output is correct
15 Correct 2 ms 508 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 0 ms 364 KB Output is correct
10 Correct 2 ms 364 KB Output is correct
11 Correct 2 ms 364 KB Output is correct
12 Correct 2 ms 364 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 364 KB Output is correct
15 Correct 2 ms 508 KB Output is correct
16 Correct 50 ms 1768 KB Output is correct
17 Correct 49 ms 1768 KB Output is correct
18 Correct 49 ms 1768 KB Output is correct
19 Correct 49 ms 1788 KB Output is correct
20 Correct 49 ms 1768 KB Output is correct
21 Correct 50 ms 2032 KB Output is correct
22 Correct 49 ms 1768 KB Output is correct
23 Correct 49 ms 1768 KB Output is correct
24 Correct 50 ms 1768 KB Output is correct