結果

問題 No.954 Result
ユーザー tunamagur0
提出日時 2020-01-03 17:11:49
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 614 bytes
コンパイル時間 1,517 ms
コンパイル使用メモリ 169,396 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-04 12:39:12
合計ジャッジ時間 2,333 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 7
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

long long memo[10000];

long long fib(int n) {
    if (memo[n] != 0) return memo[n];
    if (n == 0 || n == 1) return memo[n] = 1;
    return memo[n] = fib(n - 1) + fib(n - 2);
}

int main(void) {
    vector<long long> a(5);
    for (int i = 0; i < 5; i++) {
        cin >> a[4 - i];
    }
    fib(100);
    int cnt = 0;
    int ans = 0;
    for (int i = 0; i < 100; i++) {
        if (cnt != 0 && memo[i] != a[cnt]) {
            ans = max(cnt, ans);
            cnt = 0;
        }
        if (a[cnt] == memo[i]) cnt++;
    }
    cout << ans << endl;
    return 0;
}
0