Submission #70602

# Submission time Handle Problem Language Result Execution time Memory
70602 2018-08-23T07:20:39 Z someone_aa Stove (JOI18_stove) C++17
100 / 100
73 ms 11004 KB
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int maxn = 100100;
int arr[maxn], n, k;
bool light[maxn];
vector<pair<int,int> > diff;

int main() {
    cin>>n>>k;
    for(int i=1;i<=n;i++) {
        cin>>arr[i];
    }

    for(int i=2;i<=n;i++) {
        diff.pb(mp(arr[i]-arr[i-1], i));
    }

    light[1] = true;
    sort(diff.rbegin(), diff.rend());
    for(int i=0;i<k-1;i++) {
        light[diff[i].second] = true;
    }

    arr[0] = 0;
    int last = 1;
    int result = 0;
    for(int i=1;i<=n;i++) {
        if(light[i]) {
            result += arr[i-1] + 1 - last;
            last = arr[i];
        }
        else continue;
    }

    result += arr[n] + 1 - last;
    cout<<result;

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 376 KB Output is correct
2 Correct 3 ms 496 KB Output is correct
3 Correct 2 ms 496 KB Output is correct
4 Correct 2 ms 504 KB Output is correct
5 Correct 3 ms 556 KB Output is correct
6 Correct 2 ms 560 KB Output is correct
7 Correct 2 ms 572 KB Output is correct
8 Correct 2 ms 584 KB Output is correct
9 Correct 2 ms 588 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 376 KB Output is correct
2 Correct 3 ms 496 KB Output is correct
3 Correct 2 ms 496 KB Output is correct
4 Correct 2 ms 504 KB Output is correct
5 Correct 3 ms 556 KB Output is correct
6 Correct 2 ms 560 KB Output is correct
7 Correct 2 ms 572 KB Output is correct
8 Correct 2 ms 584 KB Output is correct
9 Correct 2 ms 588 KB Output is correct
10 Correct 5 ms 592 KB Output is correct
11 Correct 4 ms 624 KB Output is correct
12 Correct 5 ms 656 KB Output is correct
13 Correct 6 ms 712 KB Output is correct
14 Correct 6 ms 728 KB Output is correct
15 Correct 5 ms 888 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 376 KB Output is correct
2 Correct 3 ms 496 KB Output is correct
3 Correct 2 ms 496 KB Output is correct
4 Correct 2 ms 504 KB Output is correct
5 Correct 3 ms 556 KB Output is correct
6 Correct 2 ms 560 KB Output is correct
7 Correct 2 ms 572 KB Output is correct
8 Correct 2 ms 584 KB Output is correct
9 Correct 2 ms 588 KB Output is correct
10 Correct 5 ms 592 KB Output is correct
11 Correct 4 ms 624 KB Output is correct
12 Correct 5 ms 656 KB Output is correct
13 Correct 6 ms 712 KB Output is correct
14 Correct 6 ms 728 KB Output is correct
15 Correct 5 ms 888 KB Output is correct
16 Correct 71 ms 3368 KB Output is correct
17 Correct 70 ms 4460 KB Output is correct
18 Correct 67 ms 5204 KB Output is correct
19 Correct 71 ms 6192 KB Output is correct
20 Correct 71 ms 7148 KB Output is correct
21 Correct 73 ms 8108 KB Output is correct
22 Correct 73 ms 9052 KB Output is correct
23 Correct 70 ms 10036 KB Output is correct
24 Correct 65 ms 11004 KB Output is correct