結果
問題 | No.954 Result |
ユーザー |
![]() |
提出日時 | 2025-03-20 21:11:44 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 40 ms / 2,000 ms |
コード長 | 1,417 bytes |
コンパイル時間 | 189 ms |
コンパイル使用メモリ | 82,372 KB |
実行使用メモリ | 54,056 KB |
最終ジャッジ日時 | 2025-03-20 21:12:39 |
合計ジャッジ時間 | 2,830 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 7 |
other | AC * 29 |
ソースコード
# Generate the Fibonacci list up to a sufficiently large numberfib = [1, 1]while True:next_val = fib[-1] + fib[-2]fib.append(next_val)if next_val > 10**18:break# Read input and reverse it to process from the bottom ups = [int(input()) for _ in range(5)][::-1]max_n = 0# Check from n=5 down to n=1for n in range(5, 0, -1):sub = s[:n]# Check non-decreasingvalid_non_decreasing = Truefor i in range(len(sub) - 1):if sub[i] > sub[i + 1]:valid_non_decreasing = Falsebreakif not valid_non_decreasing:continue# Check Fibonacci conditionsif len(sub) == 1:# Check if the single element is a Fibonacci numberif sub[0] in fib:max_n = nbreakelse:a, b = sub[0], sub[1]# Check if a and b are consecutive Fibonacci numbersfound = Falsefor i in range(len(fib) - 1):if fib[i] == a and fib[i + 1] == b:found = Truebreakif not found:continue# Check subsequent elements follow the Fibonacci rulevalid_rest = Truefor i in range(2, len(sub)):if sub[i] != sub[i - 1] + sub[i - 2]:valid_rest = Falsebreakif valid_rest:max_n = nbreakprint(max_n)