結果

問題 No.274 The Wall
ユーザー t8m8⛄️t8m8⛄️
提出日時 2015-08-28 23:18:06
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,326 bytes
コンパイル時間 3,733 ms
コンパイル使用メモリ 75,160 KB
実行使用メモリ 60,252 KB
最終ジャッジ日時 2023-09-25 19:29:57
合計ジャッジ時間 8,721 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
55,640 KB
testcase_01 AC 123 ms
55,760 KB
testcase_02 AC 123 ms
56,180 KB
testcase_03 AC 121 ms
55,388 KB
testcase_04 AC 126 ms
55,524 KB
testcase_05 AC 125 ms
56,036 KB
testcase_06 AC 127 ms
55,952 KB
testcase_07 AC 122 ms
55,684 KB
testcase_08 AC 122 ms
56,280 KB
testcase_09 AC 124 ms
55,876 KB
testcase_10 AC 123 ms
55,956 KB
testcase_11 AC 124 ms
55,976 KB
testcase_12 AC 214 ms
59,316 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 120 ms
55,696 KB
testcase_17 AC 126 ms
55,840 KB
testcase_18 AC 122 ms
56,184 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 180 ms
55,984 KB
testcase_23 AC 190 ms
57,876 KB
testcase_24 WA -
testcase_25 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class No0274 {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);

	static void solve() {
		int n = in.nextInt();
		int m = in.nextInt();
		boolean[] f = new boolean[m];
		for (int i=0; i<n; i++) {
			int l = in.nextInt();
			int r = in.nextInt();
			if (l >= m/2) {
				int t = l;
				l = m - r - 1; r = m - t - 1;
			}

			// trace(f);

			boolean flag = true;
			for (int j=l; j<=r; j++) {
				if (f[j]) {
					flag = false;
					break;
				}
			}

			if (flag) {
				for (int j=l; j<=r; j++) {
					f[j] = true;
				}
			} else {
				int t = l;
				l = m - r - 1; r = m - t - 1;
				boolean flag2 = true;
				for (int j=l; j<=r; j++) {
					if (f[j]) {
						flag2 = false;
						break;
					}
				}

				if (flag2) {
					for (int j=l; j<=r; j++) {
						f[j] = true;
					}
				} else {
					out.println("NO");
					return;
				}
			}
		}

		out.println("YES");
	}

	public static void main(String[] args) {
		long start = System.currentTimeMillis();

		solve();
		out.flush();

		long end = System.currentTimeMillis();
		//trace(end-start + "ms");
		in.close();
		out.close();
	}

	static void trace(Object... o) { System.out.println(Arrays.deepToString(o));}
}
0