結果

問題 No.398 ハーフパイプ(2)
ユーザー りあんりあん
提出日時 2016-07-14 15:53:56
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 335 ms / 2,000 ms
コード長 1,629 bytes
コンパイル時間 1,656 ms
コンパイル使用メモリ 167,380 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-09 21:50:45
合計ジャッジ時間 6,052 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
4,380 KB
testcase_01 AC 24 ms
4,376 KB
testcase_02 AC 286 ms
4,380 KB
testcase_03 AC 294 ms
4,380 KB
testcase_04 AC 292 ms
4,376 KB
testcase_05 AC 278 ms
4,376 KB
testcase_06 AC 87 ms
4,376 KB
testcase_07 AC 178 ms
4,380 KB
testcase_08 AC 23 ms
4,376 KB
testcase_09 AC 308 ms
4,376 KB
testcase_10 AC 297 ms
4,380 KB
testcase_11 AC 270 ms
4,376 KB
testcase_12 AC 333 ms
4,376 KB
testcase_13 AC 331 ms
4,376 KB
testcase_14 AC 335 ms
4,376 KB
testcase_15 AC 210 ms
4,376 KB
testcase_16 AC 330 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main()
{
    double x;
    cin >> x;
    int sum = (int)(x * 4 + 1e-9);
    long long ans = 0;
    for (int i = 0; i < 101; i++)
    {
        if (i * 4 > sum) continue;
        
        for (int j = i; j < 101; j++)
        {
            if (j * 4 < sum) continue;
            
            int lim = j - i;
            int limsum = sum + j - i * 5;
            long dp[601][4] = {0};
            dp[0][0] = 1;
            for (int k = 0; k < 6; k++)
            {
                long next[601][4] = {0};
                for (int l = 0; l <= limsum; l++)
                {
                    if (lim == 0)
                    {
                        next[l][3] += dp[l][0] + dp[l][1] + dp[l][2] + dp[l][3];
                    }
                    else
                    {
                        next[l][1] += dp[l][0] + dp[l][1];
                        next[l][3] += dp[l][2] + dp[l][3];
                        if (l >= lim)
                        {
                            next[l][2] += dp[l - lim][0] + dp[l - lim][2];
                            next[l][3] += dp[l - lim][1] + dp[l - lim][3];
                        }
                    }
                    for (int m = 1; m < lim && m <= l; m++)
                    {
                        for (int p = 0; p < 4; p++)
                        {
                            next[l][p] += dp[l - m][p];
                        }
                    }
                }
                swap(dp, next);
            }
            ans += dp[limsum][3];
        }
    }
    cout << ans << "\n";
    return 0;
}
0