제출 #1346964

#제출 시각아이디문제언어결과실행 시간메모리
1346964po_rag526Stove (JOI18_stove)C++20
100 / 100
12 ms2372 KiB
// cd /mnt/c/users/murad/onedrive/dokumente
/// https://open.spotify.com/intl-tr/track/13XGeumHl6payK5U9fI0R7?si=c27aa63e897a4bcb
/*
??????????????????????????
??????????????????????????
??????????????????????????
??????????????????????????
??????????????????????????
??????????????????????????
??????????????????????????
??????????????????????????
??????????????????????????
??????????????????????????
??????????????????????????
??????????????????????????
??????????????????????????
'*/
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#define int long long
#define YES cout << "YES" << '\n';
#define NO cout << "NO" << '\n';
#define Yes cout << "Yes" << '\n';
#define No cout << "No" << '\n';
#define no cout << "no" << '\n';
#define yes cout << "yes" << '\n';
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(nullptr);
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define pf push_front
#define M_PI 3.14159265358979323846
#define vi vector<long long>
#define pii pair<long long, long long>
#define vii vector<pair<long long, long long>>
#define vvi vector<vector<long long>>
const long long kurdistan = 0;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
const long long LINF = 4e18;
const long long LOG = 1e8;
const long long MAXN = 50000;
const long long MAXM = 100005 + 5;
const long long sz = 200000 + 5;
// mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

template <typename T>
void print(const vector<T> &v)
{
    for (auto &x : v)
    {
        cout << x << ' ';
    }
    cout << '\n';
}

template <typename T>
void input(vector<T> &v)
{
    for (auto &x : v)
    {
        cin >> x;
    }
}

int ebob(int a, int b)
{
    int g = std::gcd(a, b);
    return g;
}
int ekob(int a, int b)
{
    int g = std::gcd(a, b);
    return (a / g) * b;
}

using namespace __gnu_pbds;
template <typename T>
using indexed_set = tree<
    T,
    null_type,
    less<T>,
    rb_tree_tag,
    tree_order_statistics_node_update>;
template <typename T>
using indexed_multiset = tree<
    pair<T, int>,
    null_type,
    less<pair<T, int>>,
    rb_tree_tag,
    tree_order_statistics_node_update>;
///--------------------TEMPLATE END-------------------------------------

void _()
{
    int n, k;
    cin >> n >> k;
    vi t(n);
    for(int i = 0; i < n; ++i)
    {
        cin >> t[i];
    }
    vi bos;
    for(int i = 1; i < n; ++i)
    {
        bos.pb(t[i] - t[i - 1]);
    }
    sort(rall(bos));
    int res = t[n - 1] - t[0];
    for(int i = 0; i < k - 1 && i < bos.size(); ++i)
    {
        res -= bos[i];
    }
    cout << res + k << '\n';
}

signed main()
{
    fastio int t = 1;
    //cin >> t;
    while (t--)
    {
        _();
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...