結果
問題 | No.116 門松列(1) |
ユーザー |
![]() |
提出日時 | 2017-10-09 18:49:05 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 5,000 ms |
コード長 | 648 bytes |
コンパイル時間 | 691 ms |
コンパイル使用メモリ | 71,348 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-25 01:32:31 |
合計ジャッジ時間 | 1,492 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> #include <string> #define REP(i, a, b) for (int i = int(a); i < int(b); i++) using namespace std; typedef long long int lli; int main() { int N; cin >> N; vector<int> v(N); REP (i, 0, N) cin >> v[i]; int ans = 0; REP (i, 0, N - 2) { int a = v[i]; int b = v[i + 1]; int c = v[i + 2]; if (a != b && b != c && c != a) { if (a > b) swap(a, b); if (b > c) swap(b, c); if (a > b) swap(a, b); if (v[i] == b || v[i + 2] == b) ans++; } } cout << ans << endl; return 0; }