Submission #285408

# Submission time Handle Problem Language Result Execution time Memory
285408 2020-08-28T22:23:08 Z Ruba_K Stove (JOI18_stove) C++14
100 / 100
26 ms 2376 KB
#include<bits/stdc++.h>

using namespace std;

#define debug(x) cout << '[' << #x << " is: " << x << "] " << '\n';
#define imod(a , n) (a % n + n ) % n

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
#define inF freopen("milkvisits.in","r",stdin );
#define outF freopen("milkvisits.out" , "w" , stdout ) ;
#define sor(v) sort(v.begin() , v.end());
#define print(v) for(auto f : v ) cout << f << " " ;
#define rsor(v) sort(v.rbegin() , v.rend());
#define rev(v) reverse(v.begin() , v.end());
#define lp(i , n) for(int x = i ; x < n ; x ++)
#define ll long long
#define read(arr , x , n) for(int i = x ; i < n ; i ++ )cin >> arr[i];
const double eps = 1e-6 , PI = acos(-1) ;
const long long OO = 1e18 ;
const ll N = 22  , oo = 1e9 + 1  , M = 2000002, mod = 1e9 + 7 , K = 12;


//                                                +_+
int32_t main(){
    // inF;outF;
    fastio;
    // Dont Forget memset


   int n , k ;
   cin >> n >> k ;


   vector<int>v(n);

   for(auto &it : v)
    cin >> it ;

    sor(v);

    ll ans = v[n - 1] + 1 - v[0];
    vector<int>V;
    for(int i = 1 ; i < n  ; i ++)V.push_back(v[i] - v[i - 1] - 1);

    rsor(V);
    for(int i = 0 ; i < k - 1 ; i++)
        ans -= V[i];

    cout << ans ;


}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 26 ms 2304 KB Output is correct
17 Correct 24 ms 2304 KB Output is correct
18 Correct 23 ms 2376 KB Output is correct
19 Correct 23 ms 2304 KB Output is correct
20 Correct 22 ms 2304 KB Output is correct
21 Correct 22 ms 2304 KB Output is correct
22 Correct 22 ms 2304 KB Output is correct
23 Correct 22 ms 2304 KB Output is correct
24 Correct 22 ms 2296 KB Output is correct