답안 #504967

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
504967 2022-01-10T11:05:12 Z Andy__Andy__ Stove (JOI18_stove) C++17
100 / 100
51 ms 2336 KB
#include <bits/stdc++.h>
#define ll long long
//#define int ll
using namespace std;

ifstream f ("test.in");
ofstream g ("test.out");

priority_queue < int > q;

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

    vector < int > v(n+5);

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

    if(n == k)
    {
        cout<<n;
        return 0;
    }

    for(int i=1;i<n;++i)
    {
        q.push( (v[i+1]-v[i]-1) );
    }

    int ans = v[n]-v[1]+1;
    k--;
    while(k--)
    {
        int x = q.top();
        ans -=x;
        q.pop();
    }

    cout<<ans;

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 304 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 300 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 300 KB Output is correct
9 Correct 1 ms 304 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 304 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 300 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 300 KB Output is correct
9 Correct 1 ms 304 KB Output is correct
10 Correct 2 ms 332 KB Output is correct
11 Correct 2 ms 332 KB Output is correct
12 Correct 2 ms 332 KB Output is correct
13 Correct 2 ms 312 KB Output is correct
14 Correct 2 ms 332 KB Output is correct
15 Correct 2 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 304 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 300 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 300 KB Output is correct
9 Correct 1 ms 304 KB Output is correct
10 Correct 2 ms 332 KB Output is correct
11 Correct 2 ms 332 KB Output is correct
12 Correct 2 ms 332 KB Output is correct
13 Correct 2 ms 312 KB Output is correct
14 Correct 2 ms 332 KB Output is correct
15 Correct 2 ms 332 KB Output is correct
16 Correct 38 ms 2212 KB Output is correct
17 Correct 40 ms 2196 KB Output is correct
18 Correct 46 ms 2200 KB Output is correct
19 Correct 40 ms 2336 KB Output is correct
20 Correct 45 ms 2216 KB Output is correct
21 Correct 47 ms 2192 KB Output is correct
22 Correct 51 ms 2208 KB Output is correct
23 Correct 47 ms 2240 KB Output is correct
24 Correct 50 ms 2208 KB Output is correct