Submission #45659

# Submission time Handle Problem Language Result Execution time Memory
45659 2018-04-15T20:01:36 Z reality Stove (JOI18_stove) C++17
100 / 100
101 ms 10656 KB
#include "bits/stdc++.h"
using namespace std;
#define fi first
#define se second
#define ll long long
#define dbg(v) cerr<<#v<<" = "<<v<<'\n'
#define vi vector<int>
#define vl vector <ll>
#define pii pair<int,int>
#define mp make_pair
#define db long double
#define pb push_back
#define all(s) s.begin(),s.end()
template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;}
template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;}
int main(void) {
    int n,k;
    cin>>n>>k;
    vi s(n);
    for (auto & it : s)
        cin>>it;
    int ans = s.back() - s[0] + 1;
    vi v;
    --k;
    for (int i = 1;i < n;++i)
        v.pb(s[i] - s[i - 1] - 1);
    sort(all(v),greater < int > ());
    for (int i = 0;i < k;++i)
        ans -= v[i];
    cout << ans << '\n';
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 360 KB Output is correct
3 Correct 2 ms 416 KB Output is correct
4 Correct 2 ms 416 KB Output is correct
5 Correct 2 ms 416 KB Output is correct
6 Correct 2 ms 536 KB Output is correct
7 Correct 2 ms 544 KB Output is correct
8 Correct 2 ms 596 KB Output is correct
9 Correct 2 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 360 KB Output is correct
3 Correct 2 ms 416 KB Output is correct
4 Correct 2 ms 416 KB Output is correct
5 Correct 2 ms 416 KB Output is correct
6 Correct 2 ms 536 KB Output is correct
7 Correct 2 ms 544 KB Output is correct
8 Correct 2 ms 596 KB Output is correct
9 Correct 2 ms 596 KB Output is correct
10 Correct 3 ms 656 KB Output is correct
11 Correct 3 ms 692 KB Output is correct
12 Correct 3 ms 736 KB Output is correct
13 Correct 5 ms 768 KB Output is correct
14 Correct 3 ms 816 KB Output is correct
15 Correct 5 ms 976 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 360 KB Output is correct
3 Correct 2 ms 416 KB Output is correct
4 Correct 2 ms 416 KB Output is correct
5 Correct 2 ms 416 KB Output is correct
6 Correct 2 ms 536 KB Output is correct
7 Correct 2 ms 544 KB Output is correct
8 Correct 2 ms 596 KB Output is correct
9 Correct 2 ms 596 KB Output is correct
10 Correct 3 ms 656 KB Output is correct
11 Correct 3 ms 692 KB Output is correct
12 Correct 3 ms 736 KB Output is correct
13 Correct 5 ms 768 KB Output is correct
14 Correct 3 ms 816 KB Output is correct
15 Correct 5 ms 976 KB Output is correct
16 Correct 60 ms 2892 KB Output is correct
17 Correct 63 ms 3856 KB Output is correct
18 Correct 59 ms 4836 KB Output is correct
19 Correct 59 ms 5924 KB Output is correct
20 Correct 59 ms 6768 KB Output is correct
21 Correct 101 ms 7748 KB Output is correct
22 Correct 63 ms 8696 KB Output is correct
23 Correct 64 ms 9676 KB Output is correct
24 Correct 72 ms 10656 KB Output is correct