結果

問題 No.185 和風
ユーザー te-shte-sh
提出日時 2016-08-31 17:31:19
言語 D
(dmd 2.107.1)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 473 bytes
コンパイル時間 709 ms
コンパイル使用メモリ 106,312 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-09-02 21:46:53
合計ジャッジ時間 1,444 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,368 KB
testcase_01 AC 2 ms
4,368 KB
testcase_02 AC 2 ms
4,368 KB
testcase_03 AC 2 ms
4,368 KB
testcase_04 AC 2 ms
4,372 KB
testcase_05 AC 1 ms
4,368 KB
testcase_06 AC 2 ms
4,372 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.algorithm, std.array, std.container, std.range, std.bitmanip;
import std.numeric, std.math, std.bigint, std.random;
import std.string, std.conv, std.stdio, std.typecons;

void main()
{
  auto n = readln.chomp.to!int;
  auto ai = iota(n)
    .map!(_ => readln.split.map!(to!int))
    .map!(rd => rd[1] - rd[0]).array;
  
  if (ai.any!(a => a <= 0) || ai.length >= 2 && ai[1..$].any!(a => a != ai.front)) {
    writeln(-1);
  } else {
    writeln(ai.front);
  }
}
0