이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 >= 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);
}
컴파일 시 표준 에러 (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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |