Submission #880404

# Submission time Handle Problem Language Result Execution time Memory
880404 2023-11-29T10:47:04 Z frostray8653 Stove (JOI18_stove) C++17
100 / 100
15 ms 3620 KB
#include <bits/stdc++.h>
#define int long long
#define IO ios::sync_with_stdio(0), cin.tie(0)
#define FOR(i, a, b) for (int i = a; i <= b; i++)
using namespace std;
using pii = pair<int, int>;
void dbg() {;}
template<class T, class ...U>
void dbg(T a, U ...b) { cout << a << " "; dbg(b...); }
void ent() { cout << "\n"; }
const int N = 100005;
int a[N];

signed main() {
    IO;
    
    int n, m;
    cin >> n >> m;
    FOR(i, 1, n) cin >> a[i];

    vector<int> len;
    FOR(i, 2, n)
        len.push_back(a[i] - (a[i - 1] + 1));
    sort(len.begin(), len.end(), greater<int>());

    int ans = a[n] + 1 - a[1];
    m--;
    FOR(i, 0, m - 1)
        ans -= len[i];
    cout << ans << "\n";

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 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 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 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 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 476 KB Output is correct
15 Correct 1 ms 508 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 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 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 476 KB Output is correct
15 Correct 1 ms 508 KB Output is correct
16 Correct 14 ms 3292 KB Output is correct
17 Correct 14 ms 3288 KB Output is correct
18 Correct 15 ms 3620 KB Output is correct
19 Correct 14 ms 3292 KB Output is correct
20 Correct 15 ms 3292 KB Output is correct
21 Correct 14 ms 3292 KB Output is correct
22 Correct 14 ms 3316 KB Output is correct
23 Correct 14 ms 3292 KB Output is correct
24 Correct 14 ms 3292 KB Output is correct