結果

問題 No.274 The Wall
ユーザー hanorverhanorver
提出日時 2015-08-28 23:50:00
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,085 bytes
コンパイル時間 668 ms
コンパイル使用メモリ 67,096 KB
実行使用メモリ 4,512 KB
最終ジャッジ日時 2023-09-25 19:31:39
合計ジャッジ時間 1,719 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>

int main() {
	int block_num, block_length;

	std::cin >> block_num >> block_length;
	
	std::vector<std::pair<int, int> > 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<int> 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;
}
0