結果
| 問題 |
No.116 門松列(1)
|
| コンテスト | |
| ユーザー |
koukonko
|
| 提出日時 | 2015-12-11 22:38:06 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 57 ms / 5,000 ms |
| コード長 | 1,159 bytes |
| コンパイル時間 | 2,035 ms |
| コンパイル使用メモリ | 77,552 KB |
| 実行使用メモリ | 37,152 KB |
| 最終ジャッジ日時 | 2024-06-25 01:12:46 |
| 合計ジャッジ時間 | 4,306 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 |
ソースコード
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) {
BufferedReader buff = new BufferedReader(new InputStreamReader(System.in));
try {
int count = Integer.parseInt(buff.readLine());
String[] box = buff.readLine().split(" ");
int[] height = new int[count];
for(int i = 0; i < count; ++i){
height[i] = Integer.parseInt(box[i]);
}
int ans = 0;
for(int i = 1; i < count-1; ++i){
int max = 0, min = 101;
boolean flag = false;
for(int j = -1; j < 2; ++j){
if(max == height[i+j] || min == height[i+j]){
flag = true;
break;
}
if(max < height[i+j]){
max = height[i+j];
}
if(min > height[i+j]){
min = height[i+j];
}
}
if(flag){
continue;
}
if(max != height[i-1] && min != height[i-1] || max != height[i+1] && min != height[i+1]){
++ans;
}
}
System.out.println(ans);
} catch (NumberFormatException e) {
e.getStackTrace();
} catch (IOException e) {
e.getStackTrace();
} catch (Exception e) {
e.getStackTrace();
}
}
}
koukonko