답안 #978252

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
978252 2024-05-09T04:50:16 Z IPZ Stove (JOI18_stove) C++17
100 / 100
55 ms 1744 KB
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin >> a >> b;
    vector<int>in,out;
    priority_queue<int>pq;
    for(int i=0;i<a;i++)
    {
        int c;
        cin >> c;
        in.push_back(c);
        out.push_back(c+1);
        if(i!=0) pq.push(in[i]-out[i-1]);
    }
    //out->in(out+1) to minus
    int now=out[a-1]-in[0];
    b--;
    while(b--)
    {
        now-=pq.top();
        pq.pop();
    }
    cout << now;
    

}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 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 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 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 2 ms 348 KB Output is correct
11 Correct 2 ms 344 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 2 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 2 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 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 2 ms 348 KB Output is correct
11 Correct 2 ms 344 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 2 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 2 ms 348 KB Output is correct
16 Correct 40 ms 1728 KB Output is correct
17 Correct 33 ms 1744 KB Output is correct
18 Correct 29 ms 1536 KB Output is correct
19 Correct 30 ms 1500 KB Output is correct
20 Correct 46 ms 1500 KB Output is correct
21 Correct 55 ms 1524 KB Output is correct
22 Correct 38 ms 1704 KB Output is correct
23 Correct 38 ms 1744 KB Output is correct
24 Correct 42 ms 1500 KB Output is correct