結果
問題 | No.116 門松列(1) |
ユーザー |
|
提出日時 | 2018-12-25 20:56:15 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 5,000 ms |
コード長 | 541 bytes |
コンパイル時間 | 1,583 ms |
コンパイル使用メモリ | 170,216 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-25 01:47:09 |
合計ジャッジ時間 | 2,372 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main(){ ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector<int> a(n); for(int i = 0; i < n; i++) { cin >> a[i]; } int ans = 0; for(int i = 0; i <= n - 3; i++) { int x = a[i]; int y = a[i + 1]; int z = a[i + 2]; cerr << x << " " << y << " " << z << endl; if(x == y || y == z || z == x) continue; int mi = min(x, min(y, z)); int mx = max(x, max(y, z)); if(mi == y || mx == y) ans++; } cout << ans << endl; return 0; }