結果
| 問題 |
No.116 門松列(1)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-10-29 16:58:34 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 57 ms / 5,000 ms |
| コード長 | 739 bytes |
| コンパイル時間 | 4,023 ms |
| コンパイル使用メモリ | 77,196 KB |
| 実行使用メモリ | 50,312 KB |
| 最終ジャッジ日時 | 2024-06-25 01:33:53 |
| 合計ジャッジ時間 | 5,663 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 |
ソースコード
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class No116 {
public static void main(String[] args) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(br.readLine());
String[] str = br.readLine().split(" ");
int[] num = new int[n];
for(int i=0; i < n; i++) num[i] = Integer.parseInt(str[i]);
System.out.println(judge(num));
}
public static int judge(int[] a){
int ans = 0;
for(int i=1; i < a.length - 1; i++){
if(a[i-1] != a[i] && a[i-1] != a[i+1] && a[i] != a[i+1]){
if(!(a[i-1] > a[i] && a[i] > a[i+1]) && !(a[i-1] < a[i] && a[i] < a[i+1])){
ans++;
}
}
}
return ans;
}
}