結果
問題 | No.116 門松列(1) |
ユーザー |
![]() |
提出日時 | 2019-05-08 14:52:12 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 641 bytes |
コンパイル時間 | 1,205 ms |
コンパイル使用メモリ | 157,860 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-02 00:27:37 |
合計ジャッジ時間 | 2,010 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
ソースコード
#include<bits/stdc++.h> using namespace std; const long long INF = 1LL << 60; #define MOD 1000000007; typedef long long ll; #define writeln(n) cout<<n<<endl; typedef pair<float, float> P; typedef pair<string, int> Psi; int d[110]; int main() { int n; cin>>n; for(int i=0; i<n; i++){ cin>>d[i]; } int cnt=0; for(int i=1; i<n-1; i++){ int mi = min(d[i-1],d[i]); int ma = max(d[i-1],d[i]); mi = min(mi,d[i+1]); ma = max(ma,d[i+1]); if((mi ==d[i] || ma ==d[i]) && d[i-1] != d[i] && d[i] != d[i+1] && d[i-1] !=d[i+1]){ cnt++; /* cout<<d[i-1]<<" "<<d[i]<<" "<<d[i+1]<<endl;*/ } } writeln(cnt); }