Submission #78686

# Submission time Handle Problem Language Result Execution time Memory
78686 2018-10-07T13:59:49 Z Saboon Stove (JOI18_stove) C++14
100 / 100
34 ms 10384 KB
#include <iostream>
#include <queue>
#include <bitset>
#include <stack>
#include <vector>
#include <cstring>
#include <cmath>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <iomanip>
#define prime first
#define alpha second
#define PB push_back
#define PF push_front
#define MP make_pair

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef unsigned long long ull;

const int maxn = 1e5 + 100;

vector <int> arr;
int t[maxn];

int main (){
    ios_base::sync_with_stdio (false);
    int n, k;
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        cin >> t[i];
        if (i > 1)
            arr.PB (t[i] - t[i - 1] - 1);
    }
    sort (arr.begin(), arr.end(), greater <int> ());
    ll ans = 0;
    for (int i = 0; i < k - 1; i++)
        ans += arr[i];
    cout << t[n] - t[1] + 1 - ans << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 540 KB Output is correct
3 Correct 2 ms 540 KB Output is correct
4 Correct 2 ms 540 KB Output is correct
5 Correct 3 ms 540 KB Output is correct
6 Correct 2 ms 572 KB Output is correct
7 Correct 3 ms 608 KB Output is correct
8 Correct 3 ms 608 KB Output is correct
9 Correct 3 ms 628 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 540 KB Output is correct
3 Correct 2 ms 540 KB Output is correct
4 Correct 2 ms 540 KB Output is correct
5 Correct 3 ms 540 KB Output is correct
6 Correct 2 ms 572 KB Output is correct
7 Correct 3 ms 608 KB Output is correct
8 Correct 3 ms 608 KB Output is correct
9 Correct 3 ms 628 KB Output is correct
10 Correct 3 ms 632 KB Output is correct
11 Correct 3 ms 664 KB Output is correct
12 Correct 3 ms 696 KB Output is correct
13 Correct 3 ms 728 KB Output is correct
14 Correct 3 ms 760 KB Output is correct
15 Correct 3 ms 792 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 540 KB Output is correct
3 Correct 2 ms 540 KB Output is correct
4 Correct 2 ms 540 KB Output is correct
5 Correct 3 ms 540 KB Output is correct
6 Correct 2 ms 572 KB Output is correct
7 Correct 3 ms 608 KB Output is correct
8 Correct 3 ms 608 KB Output is correct
9 Correct 3 ms 628 KB Output is correct
10 Correct 3 ms 632 KB Output is correct
11 Correct 3 ms 664 KB Output is correct
12 Correct 3 ms 696 KB Output is correct
13 Correct 3 ms 728 KB Output is correct
14 Correct 3 ms 760 KB Output is correct
15 Correct 3 ms 792 KB Output is correct
16 Correct 29 ms 2716 KB Output is correct
17 Correct 27 ms 3580 KB Output is correct
18 Correct 25 ms 4560 KB Output is correct
19 Correct 27 ms 5628 KB Output is correct
20 Correct 28 ms 6512 KB Output is correct
21 Correct 27 ms 7476 KB Output is correct
22 Correct 25 ms 8496 KB Output is correct
23 Correct 25 ms 9404 KB Output is correct
24 Correct 34 ms 10384 KB Output is correct