Submission #203525

# Submission time Handle Problem Language Result Execution time Memory
203525 2020-02-21T05:50:09 Z SoGood Stove (JOI18_stove) C++14
100 / 100
79 ms 2392 KB
#include <bits/stdc++.h>
using namespace std;

using ll = long long;

#define int ll


const int N = 1e5 + 11;
int n, k, a[N];
main() {
    cin>>n>>k;
    for (int i=1;i<=n;++i) cin>>a[i];
    vector<int> v;
    for (int i = 2; i <= n; ++i) v.push_back(a[i]-a[i-1]-1);
    sort(v.begin(), v.end(),greater<int>());

    int ans=0;
    --k;
    for (int i = k; i < v.size(); ++i) ans+=v[i];
    cout<<ans+n;
    return 0;
}

Compilation message

stove.cpp:11:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() {
      ^
stove.cpp: In function 'int main()':
stove.cpp:20:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = k; i < v.size(); ++i) ans+=v[i];
                     ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 256 KB Output is correct
5 Correct 4 ms 256 KB Output is correct
6 Correct 4 ms 256 KB Output is correct
7 Correct 5 ms 256 KB Output is correct
8 Correct 5 ms 256 KB Output is correct
9 Correct 5 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 256 KB Output is correct
5 Correct 4 ms 256 KB Output is correct
6 Correct 4 ms 256 KB Output is correct
7 Correct 5 ms 256 KB Output is correct
8 Correct 5 ms 256 KB Output is correct
9 Correct 5 ms 256 KB Output is correct
10 Correct 7 ms 376 KB Output is correct
11 Correct 7 ms 376 KB Output is correct
12 Correct 7 ms 376 KB Output is correct
13 Correct 7 ms 376 KB Output is correct
14 Correct 7 ms 376 KB Output is correct
15 Correct 7 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 256 KB Output is correct
5 Correct 4 ms 256 KB Output is correct
6 Correct 4 ms 256 KB Output is correct
7 Correct 5 ms 256 KB Output is correct
8 Correct 5 ms 256 KB Output is correct
9 Correct 5 ms 256 KB Output is correct
10 Correct 7 ms 376 KB Output is correct
11 Correct 7 ms 376 KB Output is correct
12 Correct 7 ms 376 KB Output is correct
13 Correct 7 ms 376 KB Output is correct
14 Correct 7 ms 376 KB Output is correct
15 Correct 7 ms 376 KB Output is correct
16 Correct 73 ms 2292 KB Output is correct
17 Correct 75 ms 2288 KB Output is correct
18 Correct 74 ms 2276 KB Output is correct
19 Correct 74 ms 2392 KB Output is correct
20 Correct 74 ms 2288 KB Output is correct
21 Correct 77 ms 2288 KB Output is correct
22 Correct 76 ms 2288 KB Output is correct
23 Correct 75 ms 2288 KB Output is correct
24 Correct 79 ms 2288 KB Output is correct