Submission #819129

# Submission time Handle Problem Language Result Execution time Memory
819129 2023-08-10T08:08:18 Z LeVanThuc Stove (JOI18_stove) C++17
100 / 100
20 ms 2972 KB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second
#define p(x,y) pair<ll,ll>(x,y)
#define BIT(i,x) ((x>>i)&1)
#define MASK(x) (1<<x)
#define ld long double
#define __builtin_popcount __builtin_popcountll
#define pll pair<ll,ll>
template<class T1,class T2>
bool maximize(T1 &x,const T2 &y)
{
    if(x<y)
    {
        x=y;
        return 1;
    }
    return 0;
}
template<class T1,class T2>
bool minimize(T1 &x,const T2 &y)
{
    if(x>y)
    {
        x=y;
        return 1;
    }
    return 0;
}
void online()
{
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
//#ifndef ONLINE_JUDGE
//    freopen("input.inp", "r", stdin);
//    freopen("output.out","w", stdout);
//#else
//#endif
}
const ll M=1e9,N=1e5+10;
ll a[N],n,k;
int main()
{
    online();
    cin>>n>>k;
    vector<ll> vt;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        if(i>1) vt.push_back(a[i]-a[i-1]-1);
    }
    ll ans=a[n]-a[1]+1;
    sort(vt.begin(),vt.end());
    k--;
    while(k--)
    {
        ans-=vt.back();
        vt.pop_back();
    }
    cout<<ans;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 392 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 392 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
16 Correct 16 ms 2972 KB Output is correct
17 Correct 15 ms 2932 KB Output is correct
18 Correct 20 ms 2904 KB Output is correct
19 Correct 15 ms 2896 KB Output is correct
20 Correct 15 ms 2936 KB Output is correct
21 Correct 15 ms 2940 KB Output is correct
22 Correct 15 ms 2900 KB Output is correct
23 Correct 15 ms 2884 KB Output is correct
24 Correct 15 ms 2968 KB Output is correct