結果

問題 No.320 眠れない夜に
ユーザー Navier_BoltzmannNavier_Boltzmann
提出日時 2023-06-16 05:37:24
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 487 bytes
コンパイル時間 653 ms
コンパイル使用メモリ 87,012 KB
実行使用メモリ 75,544 KB
最終ジャッジ日時 2023-09-06 06:12:42
合計ジャッジ時間 4,743 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 64 ms
71,432 KB
testcase_01 AC 76 ms
75,444 KB
testcase_02 AC 67 ms
75,544 KB
testcase_03 AC 68 ms
75,456 KB
testcase_04 AC 68 ms
71,016 KB
testcase_05 AC 68 ms
71,148 KB
testcase_06 AC 65 ms
71,304 KB
testcase_07 AC 65 ms
71,468 KB
testcase_08 AC 65 ms
71,136 KB
testcase_09 AC 68 ms
71,192 KB
testcase_10 AC 65 ms
71,328 KB
testcase_11 AC 65 ms
75,244 KB
testcase_12 AC 64 ms
71,476 KB
testcase_13 AC 66 ms
71,428 KB
testcase_14 AC 64 ms
71,264 KB
testcase_15 AC 68 ms
71,428 KB
testcase_16 AC 67 ms
71,144 KB
testcase_17 AC 68 ms
71,100 KB
testcase_18 AC 65 ms
71,396 KB
testcase_19 AC 65 ms
71,228 KB
testcase_20 AC 67 ms
70,948 KB
testcase_21 AC 67 ms
71,148 KB
testcase_22 AC 64 ms
71,288 KB
testcase_23 WA -
testcase_24 AC 64 ms
71,412 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 65 ms
71,248 KB
testcase_29 AC 65 ms
71,468 KB
testcase_30 AC 63 ms
71,180 KB
testcase_31 AC 66 ms
70,948 KB
testcase_32 AC 66 ms
71,284 KB
testcase_33 AC 66 ms
71,292 KB
testcase_34 AC 65 ms
71,428 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,M = map(int,input().split())

diff = 0
mem = [-1]*(N+1)
mem[1]=1
mem[2]=1
def f(n):
    if mem[n]!=-1:
        return mem[n]
    
    mem[n] = f(n-1)+f(n-2)
    return mem[n]

diff = f(N)-M
if diff<0:
    print(-1)
    exit()

ans = 0
called = [False]*(N+1)
while diff>0:
    
    now = 1
    while f(now) <= diff:
        now += 1
    
    now -= 1
    while called[now]:
        now -= 1
    now = min(now,78)
    called[now]=True
    ans += 1
    diff -= f(now)
print(ans)
    
    
0