답안 #744198

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
744198 2023-05-18T09:08:27 Z MON Stove (JOI18_stove) C++17
100 / 100
54 ms 1792 KB
#include<iostream>
#include<queue>
using namespace std;
using ull = unsigned long long;

int main()
{
    int n,k,last,x; cin >> n >> k >> last; ull ans = last; k--;
    priority_queue<int> pq;
    for(int i = 2; i <= n ; i++)
        {
            cin >> x; pq.push(x - last - 1);
            last = x;
        }

    ans = last - ans + 1;
    while(!pq.empty() && k)
        {
            ans -= pq.top();
            pq.pop(); k--;
        }

    cout << ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 292 KB Output is correct
4 Correct 0 ms 304 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 304 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 292 KB Output is correct
4 Correct 0 ms 304 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 304 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 2 ms 308 KB Output is correct
11 Correct 2 ms 312 KB Output is correct
12 Correct 3 ms 340 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 2 ms 440 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 292 KB Output is correct
4 Correct 0 ms 304 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 304 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 2 ms 308 KB Output is correct
11 Correct 2 ms 312 KB Output is correct
12 Correct 3 ms 340 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 2 ms 440 KB Output is correct
16 Correct 40 ms 1792 KB Output is correct
17 Correct 40 ms 1736 KB Output is correct
18 Correct 45 ms 1736 KB Output is correct
19 Correct 45 ms 1696 KB Output is correct
20 Correct 49 ms 1704 KB Output is correct
21 Correct 52 ms 1780 KB Output is correct
22 Correct 51 ms 1740 KB Output is correct
23 Correct 49 ms 1704 KB Output is correct
24 Correct 54 ms 1736 KB Output is correct