結果
問題 | No.116 門松列(1) |
ユーザー |
|
提出日時 | 2017-09-30 17:38:15 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 5,000 ms |
コード長 | 861 bytes |
コンパイル時間 | 1,647 ms |
コンパイル使用メモリ | 168,340 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-25 01:32:18 |
合計ジャッジ時間 | 2,239 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define FOR(i,a,b) for(int i=(a);i<(b);i++) #define REP(i,n) FOR(i,0,n) #define ALL(a) (a).begin(),(a).end() int main(){ int n;cin>>n; vector<int> a(n); REP(i,n){ cin>>a[i]; } int res=0; int sub[3]={a[0],a[1],a[2]}; cerr<<sub[0]<<"\t"<<sub[1]<<"\t"<<sub[2]<<endl; if((sub[0]!=sub[2]) and ((sub[0]<sub[1] and sub[1]>sub[2]) or (sub[0]>sub[1] and sub[1]<sub[2]))){ cerr<<"Detected"<<endl; res++; } REP(i,n-3){ sub[0]=sub[1]; sub[1]=sub[2]; sub[2]=a[3+i]; cerr<<sub[0]<<"\t"<<sub[1]<<"\t"<<sub[2]<<endl; if((sub[0]!=sub[2]) and ((sub[0]<sub[1] and sub[1]>sub[2]) or (sub[0]>sub[1] and sub[1]<sub[2]))){ res++; cerr<<"Detected"<<endl; } } cout<<res<<"\n"; return 0; }