結果
| 問題 | No.116 門松列(1) |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-01-22 22:58:19 |
| 言語 | Java (openjdk 25.0.2) |
| 結果 |
AC
|
| 実行時間 | 38 ms / 5,000 ms |
| コード長 | 984 bytes |
| 記録 | |
| コンパイル時間 | 2,787 ms |
| コンパイル使用メモリ | 83,260 KB |
| 実行使用メモリ | 45,372 KB |
| 最終ジャッジ日時 | 2026-03-11 06:18:09 |
| 合計ジャッジ時間 | 4,206 ms |
|
ジャッジサーバーID (参考情報) |
judge3_1 / judge1_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 |
ソースコード
package me.yukicoder.lv1;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
public class No0116 {
public static void main(String[] args) {
try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
int N = Integer.parseInt(br.readLine());
String[] str = br.readLine().split(" ");
int[] matsu = new int[N];
int cnt = 0;
for (int i = 0; i < N; i++) {
matsu[i] = Integer.parseInt(str[i]);
}
for (int i = 0; i < N - 2; i++) {
int[] tmp = { matsu[i], matsu[i + 1], matsu[i + 2] };
// 門松列?
cnt = isKadomatsu(tmp) ? cnt + 1 : cnt;
}
System.out.println(cnt);
} catch (IOException e) {
e.printStackTrace();
}
}
static boolean isKadomatsu(int[] matsu) {
int[] tmp = { matsu[0], matsu[1], matsu[2] };
Arrays.sort(tmp);
return (tmp[1] != matsu[1]) &&
(matsu[0] != matsu[1] && matsu[1] != matsu[2] && matsu[0] != matsu[2]);
}
}