Submission #678194

# Submission time Handle Problem Language Result Execution time Memory
678194 2023-01-05T09:43:35 Z vjudge1 Stove (JOI18_stove) C++17
100 / 100
27 ms 2192 KB
#include <bits/stdc++.h>
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define ll long long
#define ull unsigned long long
#define len(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
using namespace std;
const ll MOD = 1e9 + 7;
ll power (ll a, ll b) {
    ll result = 1;
    for (int i = 1; i <= b; i++) result *= a;
    return result;
}
ll binpow(ll a, ll b) {
    if (b == 0) return 1;
    if (b % 2 == 1) return binpow(a, b - 1) * a;
    else return binpow(a, b / 2) * binpow(a, b / 2);
}
ll fact(int x) {
    ll result = 1;
    for (int i = 2; i <= x; i++) result *= i;
    return result;
}
ll comb(int n, int k) {
    return fact(n) / fact(k) / fact(n - k);
}
void dpcomb(){
    int c[2][2];
    c[1][1] = 1;
    for (int n = 2; n <= 1000; n++) {
        c[n][1] = n;
        for (int k = 2; k <= n; k++) {
            c[n][k] = (c[n - 1][k] + c[n - 1][k - 1]) % MOD;
        }
    }
}
int a[100001];
vector < int > p;
int main() {
    //freopen("success.in", "r", stdin);
    //freopen("success.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, k;
    cin >> n >> k >> a[1];
    for (int i = 2; i <= n; i++) {
        cin >> a[i];
        p.pb(a[i - 1] + 1 - a[i]);
    }
    sort(all(p));
    ll sum = 0;
    for (int i = 0; i < k - 1; i++) {
        sum += p[i];
    }
    cout << sum - a[1] + a[n] + 1;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 324 KB Output is correct
6 Correct 1 ms 328 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 324 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 324 KB Output is correct
6 Correct 1 ms 328 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 324 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 1 ms 368 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 324 KB Output is correct
6 Correct 1 ms 328 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 324 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 1 ms 368 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 21 ms 2156 KB Output is correct
17 Correct 18 ms 2192 KB Output is correct
18 Correct 19 ms 2132 KB Output is correct
19 Correct 19 ms 2124 KB Output is correct
20 Correct 19 ms 2124 KB Output is correct
21 Correct 19 ms 2128 KB Output is correct
22 Correct 19 ms 2164 KB Output is correct
23 Correct 19 ms 2168 KB Output is correct
24 Correct 27 ms 2132 KB Output is correct