結果

問題 No.334 門松ゲーム
ユーザー pluto77pluto77
提出日時 2018-07-27 12:17:11
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 33 ms / 2,000 ms
コード長 478 bytes
コンパイル時間 114 ms
コンパイル使用メモリ 10,996 KB
実行使用メモリ 8,348 KB
最終ジャッジ日時 2023-09-13 18:52:57
合計ジャッジ時間 1,660 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,120 KB
testcase_01 AC 16 ms
8,144 KB
testcase_02 AC 25 ms
8,152 KB
testcase_03 AC 17 ms
8,080 KB
testcase_04 AC 16 ms
8,080 KB
testcase_05 AC 16 ms
8,248 KB
testcase_06 AC 20 ms
8,328 KB
testcase_07 AC 22 ms
8,152 KB
testcase_08 AC 18 ms
8,188 KB
testcase_09 AC 19 ms
8,148 KB
testcase_10 AC 33 ms
8,240 KB
testcase_11 AC 21 ms
8,116 KB
testcase_12 AC 17 ms
8,308 KB
testcase_13 AC 17 ms
8,116 KB
testcase_14 AC 19 ms
8,348 KB
testcase_15 AC 18 ms
8,156 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#yuki334
import itertools


def iskd(t,l):
    a,b,c = [l[i] for i in t]
    if a==b or b==c or a==c:
        return False
    return max(a,b,c)==b or min(a,b,c) == b
  

def solve(n,l):
 if n<3:
  return (-1, )
 for t in itertools.combinations(range(n),3):
  if not iskd(t,l):
   continue
  ks=[k for i,k in enumerate(l) if i not in t]
  res=solve(n-3,ks)
  if res==(-1, ):
   return t
 return (-1, )

n=int(input())
l=list(map(int,input().split()))        
print(*solve(n,l))
0