Submission #930971

# Submission time Handle Problem Language Result Execution time Memory
930971 2024-02-21T02:17:24 Z lftroq Stove (JOI18_stove) C++14
100 / 100
15 ms 7768 KB
/*

                                             :-=-
                                        :%@@@@@@@@@=
                                     .#@@@@@%@%@@@@@@=
                                    -@@@@@@@@@@@@@@@@@#
                                  .+@@@@@@@@@@@@@@@@@@@@.
                                  #@@@@@@@@@@@@@@@@@@@@@%
                                .*@@@@@@@@@@@@@@@@@@@@@@@=        / ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄\
                                .@@@@@@@@@@@@@@@@@@@@@@@@#       |      lftroq ♥      |
                                +@@@@@@@@@@@%%@@@@@@@@@@@@-       \_________/
                               .%@@@@@@@@@@%##%@@@@@@@@@@@#        //
                               -@@@@@@@@%%%%%%%%%@@@@@@@@@@:
                          -+-  =@@@@@%##%#%##**+#@@@@@@@@@@-
                          .+++.%@@@%##%%%%%%%#**+##%%@@@@@@+
                            +=*%@@@#*###%%#=--+=+*##%@@@@@@%.
                            :*+%@@*+**##*=======+***#@@@@@@@:
                             =+++**%@###*=++=-==++**#@@@@@@@:
                           .**===*%@@@##+=**#*==***@@@@@@@@@:
                          :+++=+*+%%@@%#==+*%#*+=++@@@@@@@@%
                          .**#*+*+**+%#+=---=***+==*@@@@@@@:
                          :**#*+=+**@%##*%#++++--=++#@@@@@@@+-::.
                         =%**###**#@@%*=*%%%%%*==++++%@@@@@@#=-----.
                      .%@@%***###@@@%*++%%%#*===+=++++%@@@@%*=-----=.
                      =**##+=+##@@@@=+%+=***#%@#+**++++%@@%+=-------=:
                    .++===++====@@@@+--==-=#%%%%+++*++++#%+=------==+=.
                   -++--=++-:::::=#@#----+--*%%*+**+++++++==-----===--+=
                   :*+=--++-::::::--=-----==-=%==+%%***++=---=---===-=++:
                    :*+--+=-::::::::---:----+=-=++##***===-::::-+----=*+:
                     .=--:::.:::-=-::---::--------++--=====-::::--:-==++
                     :=::::::--::::::--=+-:--++++==++--==:::-:::----==+=
                     *-:::::::.....:-++++++++++++++=+=---::::===-:------
                    :+:--:......:-+++++++++++++++++====---:--=-=----:-:=.
                    :==--:::.:=+++++++++++++++++++++-::===-:-===-----=--:
                    .+=--:::-:=+++++==++++++++++++++=--:.:-===+-------+=-.
                     .+==-----::-+++-:+++=====+++++++=--=======--:----==+=.
                     :+===-----------:-++====+++++++++=--==--+-:------==-::
                      +=====-::----+-::-+====+++++++++++=---==:-===:-==-==.
                      :+===========+-::::-----+++++++++++*=--======-=+=-=.
                       .=========++=-::::::----:::-++++++*+=+======+++==.
                          .=========-::::::-----:::=+++++**+=+**====-:.   .
                             *======-::::::::-:-----++++++++==++++++-
                             #======-:::::::::-------++++++++====+++=
                             =======-:::::::::----:::=+++++++=====+++
                             =====---:::::::::::------=++++++===+==++=
                             :===-:--:::::::::::-------+++++++===++=++
                             .===-:--:::::::::::::-----=+++++====++===.
                             .+=-::--::::::::::::-:-----++++++====++=+:
                             .=-:::--::::::::::::-------=+++++===-----+=
                             .=-:::--:::::::::::---------=++++==-----==+=.
                             .=-:::---:::::::::::---------+++===-----===++.
                             .=::::---:::::::-:-----------=++==-:-----===+-
                             .--:::---:::::::--------------=+=----==--===+-
                             .=::::---::::::::::-------===--==-------=--==:
                             .=--::--::::----:---:::::-:----:::-----======-
                             .=---:--:::---::::::--------------------==++++
*/
#include <bits/stdc++.h>
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1000000007LL
#define MOD2 998244353LL
#define endl '\n'
#define PI acos(-1)
#define INFINITE 2147483647LL
#define INFINITE2 9223372036854775807
#define llll pair<ll,ll>
#define ldld pair<ld,ld>
#define fi first
#define se second
#define sqrt sqrtl
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

ll a[1000005],b[1000005];

void solve()
{
    ll n,k;
    cin >> n >> k;
    for(int i=1;i<=n;i++) cin >> a[i];
    for(int i=1;i<n;i++) b[i]=(a[i+1]-a[i]-1);
    sort(b+1,b+n,greater<int>());
    ll ans=a[n]-a[1]+1;
    for(int i=1;i<k;i++) ans-=b[i];
    cout << ans << endl;
}

int main()
{
    fastIO
    //freopen("hanhhhh.inp","r",stdin);
    //freopen("hanhhhh.out","w",stdout);
    int t=1;
    //cin >> t;
    while(t--)
    solve();
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 2 ms 2396 KB Output is correct
5 Correct 1 ms 2512 KB Output is correct
6 Correct 2 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 2 ms 2396 KB Output is correct
5 Correct 1 ms 2512 KB Output is correct
6 Correct 2 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 2 ms 2396 KB Output is correct
5 Correct 1 ms 2512 KB Output is correct
6 Correct 2 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 15 ms 7516 KB Output is correct
17 Correct 15 ms 7744 KB Output is correct
18 Correct 15 ms 7760 KB Output is correct
19 Correct 14 ms 7516 KB Output is correct
20 Correct 15 ms 7516 KB Output is correct
21 Correct 15 ms 7516 KB Output is correct
22 Correct 14 ms 7512 KB Output is correct
23 Correct 14 ms 7768 KB Output is correct
24 Correct 15 ms 7512 KB Output is correct