답안 #954297

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
954297 2024-03-27T15:21:08 Z hoanganh_siuuuuuuuu Stove (JOI18_stove) C++17
100 / 100
17 ms 4948 KB
#include <bits/stdc++.h>
#define int long long
#define f(i, a, b) for(int i = a; i <= b; i++)
#define fr(i, a, b) for(int i = a; i >= b; i--)
#define pii pair <int, int>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define in insert
#define vvec vector<vector<int>>
#define fast ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

using namespace std;

const int N = 1e5 + 5;
const int M = 1e3 + 5;
int n, k, a[N], f[M][M];
vector <int> z;

signed main()
{
    fast;
    cin >> n >> k;
    f(i, 1, n) cin >> a[i];

    int res = a[n] + 1 - a[1];
    f(i, 1, n - 1) z.eb(a[i + 1] - a[i] - 1);
    sort(z.begin(), z.end(), greater <int> {});

    f(i, 0, k - 2) res -= z[i];

    cout << res;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 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
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 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 2392 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
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 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 2392 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 4824 KB Output is correct
17 Correct 14 ms 4804 KB Output is correct
18 Correct 15 ms 4828 KB Output is correct
19 Correct 17 ms 4828 KB Output is correct
20 Correct 15 ms 4828 KB Output is correct
21 Correct 15 ms 4948 KB Output is correct
22 Correct 15 ms 4828 KB Output is correct
23 Correct 17 ms 4796 KB Output is correct
24 Correct 17 ms 4828 KB Output is correct