답안 #75195

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
75195 2018-09-08T16:43:25 Z vex Stove (JOI18_stove) C++14
100 / 100
33 ms 8820 KB
#include <bits/stdc++.h>
#define maxn 100005
using namespace std;

int n,k;
long long t[maxn];
vector<long long>v;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    cin>>n>>k;
    k--;
    for(int i=0;i<n;i++)cin>>t[i];
    for(int i=1;i<n;i++)v.push_back(t[i]-t[i-1]-1);
    sort(v.begin(),v.end());

    long long sol=t[n-1]+1-t[0];
    int sz=v.size();
    for(int i=sz-1;k>0;i--)
    {
        sol-=v[i];
        k--;
    }
    cout<<sol<<endl;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 448 KB Output is correct
4 Correct 2 ms 564 KB Output is correct
5 Correct 2 ms 568 KB Output is correct
6 Correct 2 ms 568 KB Output is correct
7 Correct 2 ms 568 KB Output is correct
8 Correct 2 ms 592 KB Output is correct
9 Correct 2 ms 616 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 448 KB Output is correct
4 Correct 2 ms 564 KB Output is correct
5 Correct 2 ms 568 KB Output is correct
6 Correct 2 ms 568 KB Output is correct
7 Correct 2 ms 568 KB Output is correct
8 Correct 2 ms 592 KB Output is correct
9 Correct 2 ms 616 KB Output is correct
10 Correct 3 ms 744 KB Output is correct
11 Correct 3 ms 772 KB Output is correct
12 Correct 3 ms 772 KB Output is correct
13 Correct 3 ms 852 KB Output is correct
14 Correct 3 ms 912 KB Output is correct
15 Correct 3 ms 960 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 448 KB Output is correct
4 Correct 2 ms 564 KB Output is correct
5 Correct 2 ms 568 KB Output is correct
6 Correct 2 ms 568 KB Output is correct
7 Correct 2 ms 568 KB Output is correct
8 Correct 2 ms 592 KB Output is correct
9 Correct 2 ms 616 KB Output is correct
10 Correct 3 ms 744 KB Output is correct
11 Correct 3 ms 772 KB Output is correct
12 Correct 3 ms 772 KB Output is correct
13 Correct 3 ms 852 KB Output is correct
14 Correct 3 ms 912 KB Output is correct
15 Correct 3 ms 960 KB Output is correct
16 Correct 25 ms 3672 KB Output is correct
17 Correct 26 ms 4640 KB Output is correct
18 Correct 27 ms 5604 KB Output is correct
19 Correct 26 ms 6572 KB Output is correct
20 Correct 26 ms 7532 KB Output is correct
21 Correct 26 ms 8488 KB Output is correct
22 Correct 33 ms 8820 KB Output is correct
23 Correct 25 ms 8820 KB Output is correct
24 Correct 31 ms 8820 KB Output is correct