답안 #548837

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
548837 2022-04-14T13:10:45 Z Specialistas13 Stove (JOI18_stove) C++17
100 / 100
47 ms 2252 KB
#include <bits/stdc++.h>

using namespace std;

int n, k;
long long t[200000];
vector<long long> dist;
long long sum=0;

int main()
{
    cin>>n>>k;
    for (int i=0; i<n; i++){
        cin>>t[i];
    }
    sum=t[n-1]-t[0]+1;
    if (k==1){
        cout<<t[n-1]-t[0]+1;
    }

    else {
        for (int i=1; i<n; i++){
            dist.push_back(t[i]-t[i-1]-1);
        }
        sort(dist.begin(), dist.end());
        reverse(dist.begin(), dist.end());
        for (int i=0; i<k-1; i++){
            sum-=dist[i];
        }
        cout<<sum;
    }


    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 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 1 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 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 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 1 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 46 ms 2236 KB Output is correct
17 Correct 44 ms 2252 KB Output is correct
18 Correct 46 ms 2252 KB Output is correct
19 Correct 47 ms 2196 KB Output is correct
20 Correct 47 ms 2176 KB Output is correct
21 Correct 44 ms 2204 KB Output is correct
22 Correct 45 ms 2148 KB Output is correct
23 Correct 44 ms 2216 KB Output is correct
24 Correct 46 ms 2152 KB Output is correct