답안 #479334

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
479334 2021-10-11T11:06:47 Z Spartan117 Stove (JOI18_stove) C++14
100 / 100
24 ms 2320 KB
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

bool compare (const unsigned &a, const unsigned &b)
{
    return a>b;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    
    size_t n{}, k{};
    cin >> n >> k;
    size_t availabeMatches {k-1};
    vector<unsigned> guestsTimes(n);
    for(size_t i{}; i<n; i++)
        cin >> guestsTimes[i];
    
    vector<unsigned> timeDifferences;
    unsigned timeDifference;
    for (size_t i{}; i<n-1; i++)
    {
        timeDifference = guestsTimes[i+1]-guestsTimes[i];
        if (timeDifference!=1)
            timeDifferences.push_back(timeDifference-1);
    }
    sort(timeDifferences.begin(), timeDifferences.end(), compare);
    size_t burnedTime{n};
    for(size_t i{availabeMatches}; i<timeDifferences.size(); i++)
        burnedTime+=timeDifferences[i];
    cout << burnedTime << '\n';
    
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 312 KB Output is correct
4 Correct 1 ms 260 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 316 KB Output is correct
8 Correct 1 ms 312 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 312 KB Output is correct
4 Correct 1 ms 260 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 316 KB Output is correct
8 Correct 1 ms 312 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 320 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 2 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 312 KB Output is correct
4 Correct 1 ms 260 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 316 KB Output is correct
8 Correct 1 ms 312 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 320 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 2 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 23 ms 2256 KB Output is correct
17 Correct 21 ms 2320 KB Output is correct
18 Correct 21 ms 2248 KB Output is correct
19 Correct 22 ms 2236 KB Output is correct
20 Correct 22 ms 2236 KB Output is correct
21 Correct 23 ms 2240 KB Output is correct
22 Correct 22 ms 2256 KB Output is correct
23 Correct 24 ms 2236 KB Output is correct
24 Correct 21 ms 2256 KB Output is correct