답안 #1033835

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1033835 2024-07-25T06:49:42 Z vjudge1 Stove (JOI18_stove) C++11
100 / 100
38 ms 3540 KB
#include <bits/stdc++.h>

const long long MAXN = 1e5 + 1;

using namespace std;

long long n, k, total_time = 0, skipped_time = 0;

long long a[MAXN];

vector<long long> gaps;

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

    for (int i = 0; i < n; i ++)
    {
        cin >> a[i];
    }

    for (int i = 1; i < n; i ++)
    {
        gaps.push_back(a[i] - a[i - 1] - 1);
    }

    sort(gaps.begin(), gaps.end(), greater<long long>());

    total_time = a[n - 1] - a[0] + 1;

    for (int i = 0; i < k - 1 && i < gaps.size(); i ++)
    {
        skipped_time += gaps[i];
    }

    cout << total_time - skipped_time << "\n";
}

Compilation message

stove.cpp: In function 'int main()':
stove.cpp:31:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |     for (int i = 0; i < k - 1 && i < gaps.size(); i ++)
      |                                  ~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 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 1 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 1 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 460 KB Output is correct
15 Correct 1 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 1 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 460 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 38 ms 3540 KB Output is correct
17 Correct 30 ms 3284 KB Output is correct
18 Correct 30 ms 3260 KB Output is correct
19 Correct 34 ms 3084 KB Output is correct
20 Correct 31 ms 3276 KB Output is correct
21 Correct 29 ms 3324 KB Output is correct
22 Correct 29 ms 3252 KB Output is correct
23 Correct 37 ms 3276 KB Output is correct
24 Correct 30 ms 3284 KB Output is correct