結果
| 問題 |
No.185 和風
|
| コンテスト | |
| ユーザー |
ToniTakekawa
|
| 提出日時 | 2015-07-24 18:31:20 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 29 ms / 1,000 ms |
| コード長 | 1,100 bytes |
| コンパイル時間 | 1,141 ms |
| コンパイル使用メモリ | 112,820 KB |
| 実行使用メモリ | 27,140 KB |
| 最終ジャッジ日時 | 2024-07-08 13:00:11 |
| 合計ジャッジ時間 | 1,651 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 7 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program
{
static void Main(string[] args)
{
Console.ReadLine();
var list = new List<string>();
var line = "";
while (string.IsNullOrEmpty(line = Console.ReadLine()) == false)
{
list.Add(line);
}
var XY = list.Select(l => {
var xy = l.Split(' ');
return new { X = int.Parse(xy[0]), Y = int.Parse(xy[1]) };
});
// □ + X = Y かつ、□は正整数
// □が存在しない場合は -1 を出力
// □が存在する場合は、□の数値を出力
var S = XY.Select(xy => xy.Y - xy.X);
if( S.Where(s => s <= 0).Count() > 0 )
{
Console.WriteLine("-1");
return;
}
if( S.Distinct().Count() != 1 )
{
Console.WriteLine("-1");
return;
}
Console.WriteLine(S.First());
}
}
ToniTakekawa