結果
問題 | No.274 The Wall |
ユーザー |
|
提出日時 | 2016-11-29 17:48:20 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 1,300 bytes |
コンパイル時間 | 560 ms |
コンパイル使用メモリ | 64,212 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-22 02:11:38 |
合計ジャッジ時間 | 1,389 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 22 |
ソースコード
#include<iostream>#include<utility>#include<vector>using namespace std;#define cerr cerr << "[DBG] "#define DBG(x) cerr << #x << ": " << x << endl// http://genkisugimoto.com/jp/blog/procon/2015/04/15/print-debug-technique-in-cpp.htmltemplate<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) { for (int i = 0; i < (int)v.size(); ++i) { s << v[i]; if (i < (int)v.size()- 1) s << "\t"; } return s; }typedef long long ll;typedef pair<int, int> ip;int main(){int n,m;cin >> n >> m;vector<ip> bar;bar.reserve(n);for(int i=0; i<n; i++){int l, r;cin >> l >> r;bar.push_back(make_pair(l,r));}vector<int> d(m, 0);for(int i=0; i<n; i++){d[bar[i].first] += 1;if(bar[i].second+1 < m){d[bar[i].second+1] -= 1;}}//DBG(d);vector<int> s(m);int c = 0;for(int i=0; i<m; i++){c += d[i];s[i] = c;}//DBG(s);vector<int> count((m+1)/2, 0);for(int i=0; i<(int)count.size(); i++){count[i] += s[i];count[i] += s[m-1-i];}//DBG(count);for(int i=0; i<(int)count.size(); i++){if(count[i] > 2) {cout << "NO" << endl;return 0;}}cout << "YES" << endl;return 0;}