結果
問題 | No.116 門松列(1) |
ユーザー |
|
提出日時 | 2015-01-04 23:32:52 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 557 bytes |
コンパイル時間 | 1,449 ms |
コンパイル使用メモリ | 159,584 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-25 00:55:50 |
合計ジャッジ時間 | 2,054 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> VI; typedef vector<VI> VVI; #define REP(i, n) for(int(i)=0;(i)<(n);++(i)) int N, A[100], B[3]; int main(){ cin >> N; REP(i,N){ cin >> A[i]; } int res = 0; REP(i,N-1){ if(i == 0) continue; if(A[i-1] == A[i] || A[i] == A[i+1] || A[i-1] == A[i+1]) continue; B[0] = A[i-1], B[1] = A[i], B[2] = A[i+1]; sort(B,B+3); if(A[i-1] == B[1] || A[i+1] == B[1]) res++; } cout << res << endl; }