結果

問題 No.274 The Wall
ユーザー t8m8⛄️t8m8⛄️
提出日時 2015-08-28 23:05:55
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,327 bytes
コンパイル時間 3,450 ms
コンパイル使用メモリ 75,096 KB
実行使用メモリ 58,956 KB
最終ジャッジ日時 2023-09-25 19:28:31
合計ジャッジ時間 8,738 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
55,948 KB
testcase_01 AC 129 ms
55,716 KB
testcase_02 AC 127 ms
56,108 KB
testcase_03 AC 127 ms
55,748 KB
testcase_04 AC 125 ms
55,632 KB
testcase_05 AC 126 ms
55,548 KB
testcase_06 AC 126 ms
55,728 KB
testcase_07 AC 125 ms
55,764 KB
testcase_08 AC 126 ms
55,752 KB
testcase_09 AC 128 ms
55,440 KB
testcase_10 AC 132 ms
55,868 KB
testcase_11 AC 128 ms
55,716 KB
testcase_12 AC 210 ms
58,844 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 129 ms
55,780 KB
testcase_17 AC 131 ms
55,788 KB
testcase_18 AC 129 ms
56,096 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 193 ms
56,516 KB
testcase_23 AC 194 ms
58,856 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-r-1) {
				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