結果
| 問題 |
No.185 和風
|
| コンテスト | |
| ユーザー |
spacia
|
| 提出日時 | 2015-12-16 01:33:25 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 87 ms / 1,000 ms |
| コード長 | 648 bytes |
| コンパイル時間 | 2,132 ms |
| コンパイル使用メモリ | 74,760 KB |
| 実行使用メモリ | 51,468 KB |
| 最終ジャッジ日時 | 2024-09-16 05:27:19 |
| 合計ジャッジ時間 | 2,962 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 7 |
ソースコード
import java.io.*;
import java.util.*;
import java.math.*;
class Main185 {
public static void main (String[] args) throws IOException {
BufferedReader br =
new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(br.readLine());
int ans = -1;
boolean flg = false;
for (int i = 0; i < n; i++) {
if (flg) continue;
String[] str = br.readLine().split(" ");
int sub = Integer.parseInt(str[1]) - Integer.parseInt(str[0]);
if (sub < 1) {
flg = true;
continue;
}
if (i == 0) {
ans = sub;
} else if (ans != sub) {
flg = true;
}
}
System.out.println(flg ? -1 : ans);
}
}
spacia