結果

問題 No.1825 Except One
ユーザー srjywrdnprktsrjywrdnprkt
提出日時 2023-01-16 23:44:22
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 244 ms / 3,000 ms
コード長 1,025 bytes
コンパイル時間 1,413 ms
コンパイル使用メモリ 117,360 KB
実行使用メモリ 106,904 KB
最終ジャッジ日時 2023-08-30 05:34:26
合計ジャッジ時間 6,026 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,380 KB
testcase_01 AC 3 ms
4,496 KB
testcase_02 AC 4 ms
4,948 KB
testcase_03 AC 244 ms
106,848 KB
testcase_04 AC 103 ms
49,448 KB
testcase_05 AC 39 ms
21,232 KB
testcase_06 AC 8 ms
6,792 KB
testcase_07 AC 226 ms
98,952 KB
testcase_08 AC 226 ms
98,820 KB
testcase_09 AC 7 ms
5,932 KB
testcase_10 AC 165 ms
73,776 KB
testcase_11 AC 63 ms
30,444 KB
testcase_12 AC 114 ms
52,524 KB
testcase_13 AC 73 ms
34,872 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 6 ms
5,296 KB
testcase_16 AC 6 ms
5,552 KB
testcase_17 AC 3 ms
4,380 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 4 ms
5,016 KB
testcase_20 AC 4 ms
4,868 KB
testcase_21 AC 3 ms
4,380 KB
testcase_22 AC 4 ms
4,584 KB
testcase_23 AC 3 ms
4,520 KB
testcase_24 AC 57 ms
28,324 KB
testcase_25 AC 71 ms
34,752 KB
testcase_26 AC 14 ms
9,164 KB
testcase_27 AC 193 ms
87,572 KB
testcase_28 AC 241 ms
106,776 KB
testcase_29 AC 12 ms
8,304 KB
testcase_30 AC 14 ms
9,056 KB
testcase_31 AC 38 ms
19,456 KB
testcase_32 AC 235 ms
103,092 KB
testcase_33 AC 10 ms
7,208 KB
testcase_34 AC 244 ms
106,904 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
#include <queue>
#include <algorithm>
#include <numeric>
#include <deque>
#include <complex>
#include <cassert>

using namespace std;

int main(){

    long long N, ans=0;
    cin >> N;
    vector<long long> A(N);
    for (int i=0; i<N; i++) cin >> A[i];
    sort(A.begin(), A.end());

    vector<vector<vector<long long>>> dp(N+1, vector(N+1, vector<long long>(5001)));
    for (int i=0; i<=N; i++) dp[i][0][0] = 1;

    for (int i=1; i<=N; i++){
        for (int j=1; j<=N; j++){
            for (int k=0; k<=5000; k++){
                dp[i][j][k] += dp[i-1][j][k];
                if (k>=A[i-1]) dp[i][j][k] += dp[i-1][j-1][k-A[i-1]];
            }
        }
    }

    for (int i=0; i<N; i++){
        for (int j=1; j<N; j++){
            for (int k=0; k<=5000; k++){
                if ((k+A[i])%j == 0 && k+A[i]>=j*A[i]) ans += dp[i][j][k];
            }
        }
    }

    cout << ans << endl;

    return 0;
}
0