#include #include #include int main() { int block_num, block_length; std::cin >> block_num >> block_length; std::vector > blocks; for (int i = 0; i < block_num; i++) { int left, right; std::cin >> left >> right; blocks.push_back(std::make_pair(left, right)); } std::vector wall(block_length, 0); int max = 0; int max_index = 0; while(blocks.size() != 0) { for (int i = 0; i < blocks.size(); i++) { if (max < blocks[i].second - blocks[i].first + 1) { max = blocks[i].second - blocks[i].first + 1; max_index = i; } } for (int i = blocks[max_index].first; i <= blocks[max_index].second; i++) { if(wall[i] == 0){ wall[i] = 1; } else{ for (int i = block_length - blocks[max_index].first - 1; i >= block_length - blocks[max_index].second - 1; i--){ if(wall[i] == 0){ wall[i] = 1; }else{ std::cout << "NO" << std::endl; return 0; } } } } blocks.erase(blocks.begin() + max_index); max = 0; } std::cout << "YES" << std::endl; return 0; }