답안 #390061

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
390061 2021-04-15T08:40:33 Z ioi Stove (JOI18_stove) C++14
100 / 100
54 ms 1808 KB
#include<bits/stdc++.h>
using namespace std;

int main()
{
    int n , k ;
    cin >> n >> k ;

    k -- ;


    vector<int> v ;
    int past , f ;

    for(int i = 0 ; i < n; i ++){
        int a ;
        cin >> a ;
        if(i == 0)f = a ;

        if(i)v.push_back(a - past - 1);
        past = a ;

    }
    int ans = past + 1 - f ;


    sort(v.rbegin() , v.rend());

    for(int i = 0 ; i < k ; i ++)
        ans -= v[i];

    cout << ans ;

}

Compilation message

stove.cpp: In function 'int main()':
stove.cpp:24:20: warning: 'past' may be used uninitialized in this function [-Wmaybe-uninitialized]
   24 |     int ans = past + 1 - f ;
      |               ~~~~~^~~
stove.cpp:24:9: warning: 'f' may be used uninitialized in this function [-Wmaybe-uninitialized]
   24 |     int ans = past + 1 - f ;
      |         ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 2 ms 332 KB Output is correct
11 Correct 2 ms 332 KB Output is correct
12 Correct 2 ms 332 KB Output is correct
13 Correct 2 ms 332 KB Output is correct
14 Correct 2 ms 332 KB Output is correct
15 Correct 2 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 2 ms 332 KB Output is correct
11 Correct 2 ms 332 KB Output is correct
12 Correct 2 ms 332 KB Output is correct
13 Correct 2 ms 332 KB Output is correct
14 Correct 2 ms 332 KB Output is correct
15 Correct 2 ms 332 KB Output is correct
16 Correct 53 ms 1764 KB Output is correct
17 Correct 50 ms 1756 KB Output is correct
18 Correct 51 ms 1768 KB Output is correct
19 Correct 50 ms 1780 KB Output is correct
20 Correct 52 ms 1788 KB Output is correct
21 Correct 50 ms 1728 KB Output is correct
22 Correct 51 ms 1768 KB Output is correct
23 Correct 54 ms 1808 KB Output is correct
24 Correct 51 ms 1760 KB Output is correct