結果
| 問題 | No.116 門松列(1) |
| コンテスト | |
| ユーザー |
mits58
|
| 提出日時 | 2016-07-02 14:02:48 |
| 言語 | Java (openjdk 25.0.2) |
| 結果 |
AC
|
| 実行時間 | 58 ms / 5,000 ms |
| + 573µs | |
| コード長 | 489 bytes |
| 記録 | |
| コンパイル時間 | 1,310 ms |
| コンパイル使用メモリ | 84,084 KB |
| 実行使用メモリ | 43,092 KB |
| 最終ジャッジ日時 | 2026-07-29 12:55:40 |
| 合計ジャッジ時間 | 4,134 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 |
ソースコード
import java.util.Scanner;
public class Main{
static boolean check(int x){
if(a[x+1]>a[x] && a[x+1]>a[x+2] || a[x+1]<a[x] && a[x+1]<a[x+2]) return true;
return false;
}
static int[] a;
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
a=new int[n];
for(int i=0;i<n;i++) a[i]=sc.nextInt();
int ans=0;
for(int i=0;i+2<n;i++) if(a[i]!=a[i+1] && a[i+1]!=a[i+2] && a[i]!=a[i+2] && check(i)) ans++;
System.out.println(ans);
}
}
mits58