Submission #1017596

# Submission time Handle Problem Language Result Execution time Memory
1017596 2024-07-09T09:01:47 Z vjudge1 Stove (JOI18_stove) C++17
0 / 100
0 ms 348 KB
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
typedef pair<int, int> pii;
int min_heating_time(int N, int K, vector<pii>& events) {
    sort(events.begin(), events.end());
    priority_queue<int, vector<int>, greater<int>> pq;
    int total_heating_time = 0;
    for (auto& event : events) {
        int arrival = event.first;
        int departure = event.second;
        while (!pq.empty() && pq.top() < arrival) {
            pq.pop();
        }
        if (pq.size() < K) {
            pq.push(departure);
            total_heating_time++;
        }
    }
    return total_heating_time;
}
int main() {
    int N, K;
    cin >> N >> K;
    vector<pii> events(N);
    for (int i = 0; i < N; ++i) {
        cin >> events[i].first >> events[i].second;
    }
    int result = min_heating_time(N, K, events);
    cout << result << endl;
    return 0;
}

Compilation message

stove.cpp: In function 'int min_heating_time(int, int, std::vector<std::pair<int, int> >&)':
stove.cpp:17:23: warning: comparison of integer expressions of different signedness: 'std::priority_queue<int, std::vector<int>, std::greater<int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   17 |         if (pq.size() < K) {
      |             ~~~~~~~~~~^~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -