結果

問題 No.250 atetubouのzetubou
ユーザー kroton
提出日時 2015-08-14 09:20:44
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 3,469 ms / 5,000 ms
コード長 831 bytes
コンパイル時間 444 ms
コンパイル使用メモリ 57,712 KB
実行使用メモリ 21,208 KB
最終ジャッジ日時 2024-07-18 09:19:00
合計ジャッジ時間 55,308 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>

using namespace std;

const long long MAX_T = 1000000000000000LL;
long long cache[1501][1501];

long long patterns(int x, int d) {
    if (d == 1) {
        return 1;
    }
    if (cache[x][d] >= 0) {
        return cache[x][d];
    }
    long long result = 0;
    for (int i = 0; i <= x; ++i) {
        result += patterns(x - i, d - 1);
        if (result > MAX_T) {
            result = MAX_T + 1;
            continue;
        }
    }
    cache[x][d] = result;
    return result;
}

int main() {
    fill(&cache[0][0], &cache[1500][1500] + 1, -1);
    int q;
    cin >> q;
    for (int i = 0; i < q; ++i) {
        int d, x;
        long long t;
        cin >> d >> x >> t;
        long long p = patterns(x, d);
        cout << (p <= t ? "AC" : "ZETUBOU") << endl;
    }
    return 0;
}
0