답안 #724253

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
724253 2023-04-15T00:36:51 Z Pacybwoah Stove (JOI18_stove) C++17
100 / 100
46 ms 3232 KB
#include<iostream>
#include<vector>
#include<algorithm>
#define ll long long
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    vector<ll> t(n);
    for(int i=0;i<n;i++) cin>>t[i];
    vector<ll> inter;
    for(int i=0;i<n-1;i++) inter.push_back(t[i+1]-t[i]-1);
    sort(inter.begin(),inter.end());
    reverse(inter.begin(),inter.end());
    ll ans=t[n-1]-t[0]+1;
    for(int i=0;i<k-1;i++) ans-=inter[i];
    cout<<ans<<"\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 296 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 304 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 300 KB Output is correct
8 Correct 1 ms 304 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 296 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 304 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 300 KB Output is correct
8 Correct 1 ms 304 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 2 ms 340 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 296 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 304 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 300 KB Output is correct
8 Correct 1 ms 304 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 2 ms 340 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
16 Correct 44 ms 3104 KB Output is correct
17 Correct 44 ms 3192 KB Output is correct
18 Correct 43 ms 3112 KB Output is correct
19 Correct 45 ms 3188 KB Output is correct
20 Correct 43 ms 3140 KB Output is correct
21 Correct 45 ms 3232 KB Output is correct
22 Correct 44 ms 3116 KB Output is correct
23 Correct 44 ms 3180 KB Output is correct
24 Correct 46 ms 3184 KB Output is correct