結果

問題 No.274 The Wall
ユーザー TatamoTatamo
提出日時 2016-11-29 17:48:20
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 1,300 bytes
コンパイル時間 524 ms
コンパイル使用メモリ 64,876 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-04 02:13:55
合計ジャッジ時間 1,631 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,384 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 3 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 3 ms
4,376 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 3 ms
4,376 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 3 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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.html
template<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;
}
0