답안 #716637

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
716637 2023-03-30T15:51:37 Z vjudge1 Stove (JOI18_stove) C++17
0 / 100
1 ms 340 KB
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long int
#define oo 1e15 + 9
#define pii pair<ll, int>

const int MAX = 1e5 + 5;
int arr[MAX];

int main(){
    int n, k; cin >> n >> k;
    vector<int> dif;
    for(int i = 0; i < n; i++){
        cin >> arr[i];
    }
    for(int i = 0; i < n - 1; i++){
        if(arr[i + 1] - arr[i] - 1){
            dif.push_back(arr[i + 1] - arr[i] - 1);
        }
    }
    sort(dif.begin(), dif.end());
    int ans = n;
    for (int i = 0; i < dif.size() - k + 1; i++)
    {
        ans += dif[i];
    }
    cout << ans;
}

Compilation message

stove.cpp: In function 'int main()':
stove.cpp:25:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |     for (int i = 0; i < dif.size() - k + 1; i++)
      |                     ~~^~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Runtime error 1 ms 340 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Runtime error 1 ms 340 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Runtime error 1 ms 340 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -