結果

問題 No.1825 Except One
ユーザー momoyuumomoyuu
提出日時 2023-10-26 13:22:23
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2,590 ms / 3,000 ms
コード長 1,102 bytes
コンパイル時間 3,552 ms
コンパイル使用メモリ 254,612 KB
実行使用メモリ 417,652 KB
最終ジャッジ日時 2023-10-26 13:22:44
合計ジャッジ時間 17,417 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,372 KB
testcase_01 AC 2 ms
4,372 KB
testcase_02 AC 2 ms
4,372 KB
testcase_03 AC 1,133 ms
205,660 KB
testcase_04 AC 271 ms
86,332 KB
testcase_05 AC 72 ms
38,020 KB
testcase_06 AC 8 ms
8,716 KB
testcase_07 AC 1,066 ms
197,740 KB
testcase_08 AC 1,089 ms
207,508 KB
testcase_09 AC 7 ms
8,188 KB
testcase_10 AC 733 ms
152,596 KB
testcase_11 AC 113 ms
45,940 KB
testcase_12 AC 383 ms
102,700 KB
testcase_13 AC 162 ms
62,308 KB
testcase_14 AC 3 ms
4,372 KB
testcase_15 AC 5 ms
6,340 KB
testcase_16 AC 5 ms
6,868 KB
testcase_17 AC 2 ms
4,372 KB
testcase_18 AC 2 ms
4,372 KB
testcase_19 AC 4 ms
5,272 KB
testcase_20 AC 3 ms
4,872 KB
testcase_21 AC 3 ms
4,372 KB
testcase_22 AC 3 ms
4,432 KB
testcase_23 AC 4 ms
5,296 KB
testcase_24 AC 175 ms
60,196 KB
testcase_25 AC 71 ms
33,796 KB
testcase_26 AC 8 ms
8,104 KB
testcase_27 AC 676 ms
147,844 KB
testcase_28 AC 2,209 ms
355,348 KB
testcase_29 AC 16 ms
13,732 KB
testcase_30 AC 14 ms
12,420 KB
testcase_31 AC 61 ms
34,324 KB
testcase_32 AC 1,311 ms
232,852 KB
testcase_33 AC 18 ms
14,788 KB
testcase_34 AC 2,590 ms
417,652 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n;
    cin>>n;
    int sum = 0;
    vector<vector<vector<ll>>> dp(1,vector<vector<ll>>(sum+1,vector<ll>(101,0)));
    dp[0][0][0] = 1;
    for(int i = 0;i<n;i++){
        int a;
        cin>>a;
        sum += a;
        vector<vector<vector<ll>>> ndp(i+2,vector<vector<ll>>(sum+1,vector<ll>(101,0)));

        for(int j = 0;j<=i;j++){
            for(int k = 0;k<=sum-a;k++){
                for(int l = 0;l<=100;l++){
                    int nl = max(l,a);
                    ndp[j][k][l] += dp[j][k][l];
                    ndp[j+1][k+a][nl] += dp[j][k][l];
                }
            }
        }
        swap(ndp,dp);
    }
    ll ans = 0;
    for(int i = 2;i<=n;i++){
        for(int j = 0;j<=sum;j++){
            for(int k = 0;k<=100;k++){
                if(j%(i-1)!=0) continue;
                int ni = j / (i-1);
                if(k-ni>0) continue;
                ans += dp[i][j][k];
            }
        }
    }

    cout<<ans<<endl;
}
0