답안 #718322

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
718322 2023-04-03T21:11:54 Z mshandilya Stove (JOI18_stove) C++17
100 / 100
18 ms 2264 KB
//required macros and template
#include <bits/stdc++.h>
using namespace std;

//type definitions
#define vc vector
typedef vc<int> vi;

//main method
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, k, ans;
    cin>>n>>k;
    ans = n;
    vi t(n), x;
    for(int i = 0; i<n; i++) {
        cin >> t[i];
        if(i and t[i]!=t[i-1]+1)
            x.push_back(t[i]-t[i-1]-1);
    }
    sort(x.begin(), x.end());
    for(int i = x.size()-k; i>=0; i--)
        ans += x[i];
    cout<<ans<<"\n";
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 320 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 320 KB Output is correct
7 Correct 0 ms 320 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 320 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 320 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 320 KB Output is correct
7 Correct 0 ms 320 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 320 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 372 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 328 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 320 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 320 KB Output is correct
7 Correct 0 ms 320 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 320 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 372 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 328 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 18 ms 2240 KB Output is correct
17 Correct 17 ms 2136 KB Output is correct
18 Correct 17 ms 2128 KB Output is correct
19 Correct 17 ms 2136 KB Output is correct
20 Correct 17 ms 2136 KB Output is correct
21 Correct 18 ms 2240 KB Output is correct
22 Correct 17 ms 2136 KB Output is correct
23 Correct 18 ms 2136 KB Output is correct
24 Correct 17 ms 2264 KB Output is correct