結果

問題 No.360 増加門松列
ユーザー beet
提出日時 2019-03-16 20:54:39
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 733 bytes
コンパイル時間 2,271 ms
コンパイル使用メモリ 198,752 KB
最終ジャッジ日時 2025-01-06 22:31:14
ジャッジサーバーID
(参考情報)
judge3 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
Int is_inc_kado(Int a,Int b,Int c){
  if(a==b||b==c||c==a) return 0;
  if(a<b&&b>c&&a<c) return 1;
  if(a>b&&b<c&&a<c) return 1;
  return 0;
}
signed main(){
  Int n=7;
  vector<Int> d(n);
  for(Int i=0;i<n;i++) cin>>d[i];

  auto YES=[](){cout<<"YES"<<endl;exit(0);};
  sort(d.begin(),d.end());
  do{
    Int flg=1;
    for(Int i=1;i+1<n;i++) flg&=is_inc_kado(d[i-1],d[i],d[i+1]);
    if(flg) YES();
  }while(next_permutation(d.begin(),d.end()));
  
  
  cout<<"NO"<<endl;
  return 0;
}
0