結果
問題 | No.116 門松列(1) |
ユーザー | koukonko |
提出日時 | 2015-12-11 22:38:06 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 45 ms / 5,000 ms |
コード長 | 1,159 bytes |
コンパイル時間 | 2,002 ms |
コンパイル使用メモリ | 73,936 KB |
実行使用メモリ | 49,832 KB |
最終ジャッジ日時 | 2023-09-07 06:52:13 |
合計ジャッジ時間 | 4,071 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge15 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 43 ms
49,768 KB |
testcase_01 | AC | 43 ms
49,596 KB |
testcase_02 | AC | 42 ms
49,436 KB |
testcase_03 | AC | 44 ms
49,344 KB |
testcase_04 | AC | 43 ms
49,360 KB |
testcase_05 | AC | 44 ms
49,336 KB |
testcase_06 | AC | 44 ms
49,384 KB |
testcase_07 | AC | 44 ms
49,376 KB |
testcase_08 | AC | 43 ms
49,324 KB |
testcase_09 | AC | 43 ms
49,292 KB |
testcase_10 | AC | 43 ms
49,456 KB |
testcase_11 | AC | 43 ms
49,244 KB |
testcase_12 | AC | 42 ms
49,312 KB |
testcase_13 | AC | 42 ms
49,832 KB |
testcase_14 | AC | 43 ms
49,420 KB |
testcase_15 | AC | 44 ms
49,180 KB |
testcase_16 | AC | 44 ms
49,356 KB |
testcase_17 | AC | 43 ms
49,496 KB |
testcase_18 | AC | 43 ms
49,248 KB |
testcase_19 | AC | 43 ms
49,588 KB |
testcase_20 | AC | 44 ms
47,280 KB |
testcase_21 | AC | 44 ms
49,452 KB |
testcase_22 | AC | 44 ms
49,428 KB |
testcase_23 | AC | 45 ms
49,592 KB |
ソースコード
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(); } } }