답안 #886775

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
886775 2023-12-12T22:51:48 Z Maite_Morale Stove (JOI18_stove) C++14
100 / 100
16 ms 4828 KB
#include<bits/stdc++.h>
#define F first
#define S second
#define MAX 500005
#define oo 1e18
#define mod 1000000007
#define fast_in ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);cout.setf(ios::fixed);cout.precision(0);
using namespace std;
typedef long long ll;
#define pll pair<ll , ll>
#define vll vector<ll>
#define vvll vector<vll>
#define vpll vector<pll>
 
ll n,a[MAX],k; 
int main(){
    fast_in
    cin>>n>>k;vll v;k--;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(i>0)v.push_back(-(a[i]-a[i-1]-1));
    }sort(v.begin(),v.end());
    ll r=a[n-1]+1-a[0];k=min(k,(ll)v.size());
    for(int i=0;i<k;i++){
        r+=v[i];
    }cout<<r;
return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 15 ms 4060 KB Output is correct
17 Correct 15 ms 4676 KB Output is correct
18 Correct 16 ms 4828 KB Output is correct
19 Correct 14 ms 4704 KB Output is correct
20 Correct 15 ms 4572 KB Output is correct
21 Correct 15 ms 4572 KB Output is correct
22 Correct 14 ms 4572 KB Output is correct
23 Correct 14 ms 4568 KB Output is correct
24 Correct 16 ms 4572 KB Output is correct