Submission #825463

# Submission time Handle Problem Language Result Execution time Memory
825463 2023-08-14T21:07:55 Z Isam Stove (JOI18_stove) C++17
100 / 100
16 ms 3008 KB
#include<iostream>
#include<random>
#include<chrono>
#include<vector>
#include<algorithm>
#define oo 1000000001
#define all(v) v.begin(),v.end()

using namespace std;
using ll = long long;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int sz = 1e5 + 3;
ll T[sz];
int n, k;
int main(){
    cin.tie()->sync_with_stdio(false);
    cin >> n >> k;
    vector<ll> dif;
    cin >> T[1];
    for(register int i = 2; i <= n; ++i){
        cin >> T[i];
        dif.emplace_back(T[i] - T[i-1]);
    }
    if(n <= k){
        cout << n << '\n';
        exit(0);
    }
    sort(all(dif));
    ll ans(0);
    for(register int i = 0; i < n - k; ++i) ans += dif[i];
    cout << ans + k << '\n';


    exit(0);
}

Compilation message

stove.cpp: In function 'int main()':
stove.cpp:22:22: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   22 |     for(register int i = 2; i <= n; ++i){
      |                      ^
stove.cpp:32:22: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   32 |     for(register int i = 0; i < n - k; ++i) ans += dif[i];
      |                      ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 336 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 336 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 336 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 15 ms 2936 KB Output is correct
17 Correct 15 ms 2968 KB Output is correct
18 Correct 15 ms 3008 KB Output is correct
19 Correct 16 ms 2980 KB Output is correct
20 Correct 16 ms 2900 KB Output is correct
21 Correct 15 ms 2928 KB Output is correct
22 Correct 15 ms 2932 KB Output is correct
23 Correct 15 ms 2900 KB Output is correct
24 Correct 15 ms 2900 KB Output is correct