답안 #392310

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
392310 2021-04-20T19:18:26 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];
    }
    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:19:26: warning: comparison of integer expressions of different signedness: 'long long int' and 'long long unsigned int' [-Wsign-compare]
   19 |     for(ll i=v.size()-1;i>=v.size()-k+1;i--) {
      |                         ~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Runtime error 1 ms 332 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Runtime error 1 ms 332 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Runtime error 1 ms 332 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -