Submission #1080178

#TimeUsernameProblemLanguageResultExecution timeMemory
1080178raphaelpFire (BOI24_fire)C++14
0 / 100
1 ms604 KiB
#include <bits/stdc++.h> using namespace std; int main() { int N, M; cin >> N >> M; vector<pair<int, int>> Intervals; for (int i = 0; i < N; i++) { int l, r; cin >> l >> r; if (r >= l) { Intervals.push_back({l, r}); Intervals.push_back({l + M, r + M}); } else { Intervals.push_back({l, r + M}); } } sort(Intervals.begin(), Intervals.end()); deque<pair<int, int>> DQ; int best = 1000000000; pair<int, int> next = {-1, -1}; for (int i = 0; i < Intervals.size(); i++) { if (DQ.empty() || DQ.back().second < Intervals[i].first) { if (next.first == -1) { while (!DQ.empty()) DQ.pop_front(); } else { DQ.push_back({next.second, next.first}); while (DQ.back().second - DQ.front().first + 1 >= M) { best = min(best, (int)DQ.size()); DQ.pop_front(); } } next = {-1, -1}; } next = max(next, {Intervals[i].second, Intervals[i].first}); } cout << ((best == 1000000000) ? -1 : best); }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:26:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |     for (int i = 0; i < Intervals.size(); i++)
      |                     ~~^~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...