답안 #163372

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
163372 2019-11-12T21:42:53 Z Kubalionzzale Stove (JOI18_stove) C++14
100 / 100
150 ms 6436 KB
#include <iostream>
#include <set>

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

    int a[100010];
    std::multiset<int> seti;
    long long ans = n;
    for (int i = 0; i < n; ++i)
    {
        std::cin >> a[i];
        if (i > 0)
            seti.insert(a[i] - a[i - 1] - 1);
    }

    int cnt = 0;
    int maxi = n - k;

    for (auto it : seti)
    {
        int val = it;
        if (cnt >= maxi)
            break;
        else
        {
            ans += val;
            ++cnt;
        }
    }

    std::cout << ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 380 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 380 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 5 ms 504 KB Output is correct
11 Correct 5 ms 504 KB Output is correct
12 Correct 5 ms 504 KB Output is correct
13 Correct 5 ms 504 KB Output is correct
14 Correct 5 ms 504 KB Output is correct
15 Correct 9 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 380 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 5 ms 504 KB Output is correct
11 Correct 5 ms 504 KB Output is correct
12 Correct 5 ms 504 KB Output is correct
13 Correct 5 ms 504 KB Output is correct
14 Correct 5 ms 504 KB Output is correct
15 Correct 9 ms 504 KB Output is correct
16 Correct 146 ms 6324 KB Output is correct
17 Correct 141 ms 6336 KB Output is correct
18 Correct 132 ms 6392 KB Output is correct
19 Correct 133 ms 6300 KB Output is correct
20 Correct 132 ms 6436 KB Output is correct
21 Correct 150 ms 6392 KB Output is correct
22 Correct 136 ms 6392 KB Output is correct
23 Correct 122 ms 6428 KB Output is correct
24 Correct 123 ms 6360 KB Output is correct