結果

問題 No.360 増加門松列
ユーザー Hachimori
提出日時 2016-04-17 22:56:26
言語 Python2
(2.7.18)
結果
AC  
実行時間 20 ms / 2,000 ms
コード長 671 bytes
コンパイル時間 66 ms
コンパイル使用メモリ 7,040 KB
実行使用メモリ 6,528 KB
最終ジャッジ日時 2024-12-24 04:30:35
合計ジャッジ時間 1,077 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python
#coding:utf8

import itertools


def read():
    return map(int, raw_input().split())


def isZoukaKadomatsu(A1, A2, A3):
    return len(set([A1, A2, A3])) == 3 and \
           (A2 > max(A1, A3) or A2 < min(A1, A3)) and \
           A1 < A3


def work(vList):

    for candi in itertools.permutations(vList, len(vList)):
        isOK = True
        
        for i in range(len(vList) - 2):
            if not isZoukaKadomatsu(candi[i], candi[i + 1], candi[i + 2]):
                isOK = False
                break

        if isOK:
            print "YES"
            return
    
    print "NO"

    
if __name__ == "__main__":
    work(read())

0