답안 #1010730

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1010730 2024-06-29T10:04:59 Z ASGA_RedSea Stove (JOI18_stove) C++17
100 / 100
40 ms 6496 KB
/**

                                    * بسم الله الرحمن الرحيم *

                ﴾ رَبِّ اشْرَحْ لِي صَدْرِي * وَيَسِّرْ لِي أَمْرِي * وَاحْلُلْ عُقْدَةً مِّن لِّسَانِي * يَفْقَهُوا قَوْلِي ﴿

*/

/// author : "ASGA"

#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define ONLINE 0
#ifdef ONLINE_JUDGE
    #undef ONLINE;
    #define ONLINE 1
#endif

#define dbg(a) if(!ONLINE)cout << a << ' ';

const ll inf = 1e18;

signed main(){
    ios_base::sync_with_stdio(0);cin.tie();

    int n,k;cin >> n >> k;
    vector <int> a(n);
    for(int& i : a)cin >> i;
    ll ans = a.back() + 1 - a[0];
    multiset <int> s;
    for(int i = 0;i + 1 < n;i++)s.insert(a[i + 1] - a[i]);

    auto i = s.rbegin();
    while(--k){ans -= (*i++);ans++;}

    cout << ans << '\n';

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 600 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
13 Correct 1 ms 500 KB Output is correct
14 Correct 1 ms 600 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 600 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
13 Correct 1 ms 500 KB Output is correct
14 Correct 1 ms 600 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 33 ms 6480 KB Output is correct
17 Correct 33 ms 6480 KB Output is correct
18 Correct 32 ms 6492 KB Output is correct
19 Correct 37 ms 6484 KB Output is correct
20 Correct 40 ms 6372 KB Output is correct
21 Correct 34 ms 6496 KB Output is correct
22 Correct 34 ms 6480 KB Output is correct
23 Correct 35 ms 6484 KB Output is correct
24 Correct 34 ms 6484 KB Output is correct