답안 #360218

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
360218 2021-01-27T20:13:52 Z Runtime_error_ Stove (JOI18_stove) C++14
100 / 100
60 ms 3192 KB
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll inf = 1e5+9;
ll n,k,a[inf],ans;
vector<ll> v;

int main(){
    cin>>n>>k;
    for(ll i=1;i<=n;i++)
        cin>>a[i];
    ans = a[n]+1 - a[1];
    for(ll i=2;i<=n;i++)
        v.push_back(a[i]-a[i-1]-1);
    sort(v.begin(),v.end());
    k--;
    while(k-- && !v.empty())
        ans -= v.back(),v.pop_back();
    cout<<ans<<endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 2 ms 492 KB Output is correct
11 Correct 2 ms 492 KB Output is correct
12 Correct 2 ms 492 KB Output is correct
13 Correct 2 ms 492 KB Output is correct
14 Correct 2 ms 492 KB Output is correct
15 Correct 2 ms 492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 2 ms 492 KB Output is correct
11 Correct 2 ms 492 KB Output is correct
12 Correct 2 ms 492 KB Output is correct
13 Correct 2 ms 492 KB Output is correct
14 Correct 2 ms 492 KB Output is correct
15 Correct 2 ms 492 KB Output is correct
16 Correct 50 ms 3172 KB Output is correct
17 Correct 51 ms 3172 KB Output is correct
18 Correct 60 ms 3172 KB Output is correct
19 Correct 50 ms 3172 KB Output is correct
20 Correct 53 ms 3172 KB Output is correct
21 Correct 52 ms 3172 KB Output is correct
22 Correct 52 ms 3172 KB Output is correct
23 Correct 51 ms 3192 KB Output is correct
24 Correct 51 ms 3172 KB Output is correct