結果
問題 | No.274 The Wall |
ユーザー |
![]() |
提出日時 | 2019-07-16 20:24:48 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 29 ms / 2,000 ms |
コード長 | 1,258 bytes |
コンパイル時間 | 933 ms |
コンパイル使用メモリ | 112,720 KB |
実行使用メモリ | 26,260 KB |
最終ジャッジ日時 | 2024-06-22 02:29:12 |
合計ジャッジ時間 | 2,524 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 22 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;using System.Linq;//リストの使用using System.Collections.Generic;using System.Text;//テキストの高速出力に必要class Program{static void Main(){string[] input = Console.ReadLine().Split(' ');int n = int.Parse(input[0]);int m = int.Parse(input[1]);int left = 0;int right = m-1;bool answer = true;int[][] vertexes = new int[n][];for(int i = 0; i < n; i++){int[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);if(nums[0] > m-1-nums[1]){int swapMemo = nums[0];nums[0] = m-1-nums[1];nums[1] = m-1-swapMemo;}vertexes[i] = new int[2];vertexes[i][0] = nums[0];vertexes[i][1] = nums[1];}Array.Sort(vertexes, (a, b) => a[0].CompareTo(b[0]));for(int i = 0; i < n; i++){if(vertexes[i][0] >= left) left = vertexes[i][1]+1;else if(m-1-vertexes[i][0] <= right){right = m-1-vertexes[i][1]-1;}else{answer = false;break;}//Console.WriteLine(left+" "+right);if(left-1 > right){answer = false;break;}}Console.WriteLine(answer?"YES":"NO");}}