Submission #392316

# Submission time Handle Problem Language Result Execution time Memory
392316 2021-04-20T19:20:51 Z wildturtle Stove (JOI18_stove) C++14
0 / 100
1 ms 332 KB
#include<bits/stdc++.h>
#define ll long long
#define f first
#define sc second
using namespace std;
ll a,b,c,d,i,e,f,g,n,m,k,l,idx,B[500005],le,ri,mid,ans;
ll A[500005];
vector <ll> v;
int main() {
    cin>>n>>k;
    for(ll i=1;i<=n;i++) {
        cin>>A[i];
    }
    if(n==1) { cout<<1; return 0; }
    sort(A+1,A+1+n);
    for(ll i=1;i<n;i++) {
        v.push_back(A[i+1]-A[i]-1);
    }
    sort(v.begin(),v.end());
    for(ll i=v.size()-1;i>=v.size()-k+1;i--) {
        a+=v[i];
    }
    cout<<(A[n]+1)-A[1]-a;
}

Compilation message

stove.cpp: In function 'int main()':
stove.cpp:20:26: warning: comparison of integer expressions of different signedness: 'long long int' and 'long long unsigned int' [-Wsign-compare]
   20 |     for(ll i=v.size()-1;i>=v.size()-k+1;i--) {
      |                         ~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Runtime error 1 ms 332 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Runtime error 1 ms 332 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Runtime error 1 ms 332 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -