結果
問題 | No.274 The Wall |
ユーザー |
![]() |
提出日時 | 2015-10-01 20:05:01 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 693 bytes |
コンパイル時間 | 2,264 ms |
コンパイル使用メモリ | 161,240 KB |
実行使用メモリ | 7,328 KB |
最終ジャッジ日時 | 2025-03-17 18:50:30 |
合計ジャッジ時間 | 2,631 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 23 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> que; for (int i = 0; i < n; ++i) { int l, r; cin >> l >> r; if (l > m - r - 1) que.push(make_pair(m - r - 1, m - l - 1)); else que.push(make_pair(l, r)); } int t = -1; while (!que.empty()) { auto now = que.top(); que.pop(); if (t >= now.first) { if (now.first >= m - now.second - 1) { cout << "NO" << endl; return 0; } que.push(make_pair(m - now.second - 1, m - now.first - 1)); } else { t = now.second; } } cout << "YES" << endl; }