Submission #146923

# Submission time Handle Problem Language Result Execution time Memory
146923 2019-08-26T15:55:01 Z willi19 Stove (JOI18_stove) C++14
100 / 100
94 ms 3356 KB
#include <bits/stdc++.h>
int n,k;
long long t[100100],ans;
using namespace std;
priority_queue<long long> pq;
int main()
{
    cin>>n>>k;
    for(int i=0;i<n;i++)
        cin>>t[i];
    sort(t,t+n);
    ans=t[n-1]+1-t[0];
    for(int i=0;i<n-1;i++)
        pq.push(t[i+1]-t[i]-1);
    k--;
    while(!pq.empty()&&k--)
    {
        ans-=pq.top();
        pq.pop();
    }
    cout<<ans;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 380 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 380 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 4 ms 504 KB Output is correct
11 Correct 5 ms 412 KB Output is correct
12 Correct 5 ms 504 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 5 ms 504 KB Output is correct
15 Correct 5 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 380 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 4 ms 504 KB Output is correct
11 Correct 5 ms 412 KB Output is correct
12 Correct 5 ms 504 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 5 ms 504 KB Output is correct
15 Correct 5 ms 504 KB Output is correct
16 Correct 80 ms 3356 KB Output is correct
17 Correct 80 ms 3280 KB Output is correct
18 Correct 81 ms 3228 KB Output is correct
19 Correct 85 ms 3264 KB Output is correct
20 Correct 86 ms 3280 KB Output is correct
21 Correct 92 ms 3272 KB Output is correct
22 Correct 93 ms 3156 KB Output is correct
23 Correct 94 ms 3188 KB Output is correct
24 Correct 93 ms 3312 KB Output is correct