結果

問題 No.274 The Wall
ユーザー GrenacheGrenache
提出日時 2015-08-28 23:09:19
言語 Java19
(openjdk 21)
結果
AC  
実行時間 237 ms / 2,000 ms
コード長 1,240 bytes
コンパイル時間 3,460 ms
コンパイル使用メモリ 77,316 KB
実行使用メモリ 60,156 KB
最終ジャッジ日時 2023-09-04 01:59:37
合計ジャッジ時間 9,398 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
56,000 KB
testcase_01 AC 126 ms
55,948 KB
testcase_02 AC 126 ms
55,572 KB
testcase_03 AC 199 ms
58,244 KB
testcase_04 AC 126 ms
56,008 KB
testcase_05 AC 125 ms
55,856 KB
testcase_06 AC 127 ms
55,872 KB
testcase_07 AC 126 ms
55,808 KB
testcase_08 AC 126 ms
55,900 KB
testcase_09 AC 126 ms
55,548 KB
testcase_10 AC 125 ms
55,788 KB
testcase_11 AC 211 ms
59,172 KB
testcase_12 AC 228 ms
59,796 KB
testcase_13 AC 157 ms
55,892 KB
testcase_14 AC 199 ms
59,304 KB
testcase_15 AC 214 ms
58,724 KB
testcase_16 AC 220 ms
59,216 KB
testcase_17 AC 217 ms
59,452 KB
testcase_18 AC 218 ms
59,212 KB
testcase_19 AC 222 ms
59,648 KB
testcase_20 AC 230 ms
60,012 KB
testcase_21 AC 228 ms
59,852 KB
testcase_22 AC 222 ms
59,200 KB
testcase_23 AC 227 ms
59,572 KB
testcase_24 AC 232 ms
59,700 KB
testcase_25 AC 237 ms
60,156 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.Scanner;


public class Main_yukicoder274 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int m = sc.nextInt();

        Pair[] b = new Pair[n * 2];
        for (int i = 0; i < n; i++) {
        	int l = sc.nextInt();
        	int r = sc.nextInt();
        	b[i * 2] = new Pair(l, r);
        	b[i * 2 + 1] = new Pair(m - 1 - r, m - 1 - l);
        }
        Arrays.sort(b);

        boolean flag = true;
        int pre1 = -1;
        int pre2 = -1;
        for (int i = 0; i < 2 * n; i++) {
        	if (b[i].l <= pre2) {
        		flag = false;
        		break;
        	}
        	int[] tmp = {pre1, pre2, b[i].r};
        	Arrays.sort(tmp);
        	pre1 = tmp[2];
        	pre2 = tmp[1];
        }

        if (flag) {
        	System.out.println("YES");
        } else {
        	System.out.println("NO");
        }

        sc.close();
    }
    
    private static class Pair implements Comparable<Pair> {
    	int l;
    	int r;
    	
    	Pair(int l, int r) {
    		this.l = l;
    		this.r = r;
    	}

    	@Override
		public int compareTo(Pair o) {
			return Double.compare(this.l, o.l);
		}
    }
}
0