답안 #1049742

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1049742 2024-08-09T04:38:09 Z vjudge1 Stove (JOI18_stove) C++17
100 / 100
27 ms 604 KB
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, k;
    cin>>n>>k;
    vector<int> a(n-1);
    int f;
    int s;
    cin>>s;
    for(int i = 0;i<n-1;i++){
        cin>>f;
        a[i] = f-s+1;
        s = f;
    }
    if(k>=n){
        cout<<n<<endl;
        return 0;
    }
    sort(a.begin(),a.end());
    int l = n - k;
    int ans = 0;
    int i = 0;
    while(l>0){
        ans+=a[i];
        l--;
        i++;
    }
    cout<<k-(n-k)+ans;

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 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 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 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 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 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 344 KB Output is correct
16 Correct 23 ms 604 KB Output is correct
17 Correct 24 ms 604 KB Output is correct
18 Correct 27 ms 600 KB Output is correct
19 Correct 24 ms 604 KB Output is correct
20 Correct 27 ms 600 KB Output is correct
21 Correct 23 ms 604 KB Output is correct
22 Correct 24 ms 604 KB Output is correct
23 Correct 23 ms 604 KB Output is correct
24 Correct 23 ms 604 KB Output is correct