Submission #914666

# Submission time Handle Problem Language Result Execution time Memory
914666 2024-01-22T13:47:56 Z Aiperiii Stove (JOI18_stove) C++14
100 / 100
40 ms 3328 KB
#include <bits/stdc++.h>
#define int long long
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
using namespace std;
signed main(){
    int n,k;
    cin>>n>>k;
    vector <int> a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    vector <int> v;
    for(int i=1;i<n;i++){
        v.pb(a[i]-a[i-1]);
    }
    sort(all(v));
    int ans=k;
    for(int i=0;i<v.size()-k+1;i++){
        ans+=v[i];
    }
    cout<<ans<<"\n";
}

Compilation message

stove.cpp: In function 'int main()':
stove.cpp:19:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'long long unsigned int' [-Wsign-compare]
   19 |     for(int i=0;i<v.size()-k+1;i++){
      |                 ~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 436 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 436 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 2 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 2 ms 348 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 2 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 436 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 2 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 2 ms 348 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 2 ms 348 KB Output is correct
16 Correct 35 ms 3248 KB Output is correct
17 Correct 35 ms 3272 KB Output is correct
18 Correct 35 ms 3276 KB Output is correct
19 Correct 38 ms 3240 KB Output is correct
20 Correct 35 ms 3276 KB Output is correct
21 Correct 40 ms 3272 KB Output is correct
22 Correct 34 ms 3328 KB Output is correct
23 Correct 35 ms 3124 KB Output is correct
24 Correct 36 ms 3284 KB Output is correct