結果

問題 No.1825 Except One
ユーザー srjywrdnprktsrjywrdnprkt
提出日時 2023-05-25 00:05:41
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 204 ms / 3,000 ms
コード長 1,002 bytes
コンパイル時間 1,321 ms
コンパイル使用メモリ 118,212 KB
実行使用メモリ 106,872 KB
最終ジャッジ日時 2023-08-25 14:58:38
合計ジャッジ時間 4,955 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 3 ms
4,896 KB
testcase_03 AC 204 ms
106,872 KB
testcase_04 AC 90 ms
49,768 KB
testcase_05 AC 31 ms
21,264 KB
testcase_06 AC 6 ms
6,560 KB
testcase_07 AC 185 ms
98,880 KB
testcase_08 AC 194 ms
99,136 KB
testcase_09 AC 6 ms
6,052 KB
testcase_10 AC 140 ms
73,768 KB
testcase_11 AC 50 ms
30,640 KB
testcase_12 AC 90 ms
52,332 KB
testcase_13 AC 58 ms
34,840 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 4 ms
5,308 KB
testcase_16 AC 3 ms
5,396 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 3 ms
5,008 KB
testcase_20 AC 3 ms
5,140 KB
testcase_21 AC 2 ms
4,428 KB
testcase_22 AC 2 ms
4,468 KB
testcase_23 AC 2 ms
4,628 KB
testcase_24 AC 46 ms
28,304 KB
testcase_25 AC 56 ms
34,728 KB
testcase_26 AC 11 ms
9,072 KB
testcase_27 AC 163 ms
87,500 KB
testcase_28 AC 198 ms
106,836 KB
testcase_29 AC 9 ms
8,380 KB
testcase_30 AC 10 ms
9,072 KB
testcase_31 AC 28 ms
19,520 KB
testcase_32 AC 191 ms
102,748 KB
testcase_33 AC 7 ms
7,340 KB
testcase_34 AC 203 ms
106,816 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;
using ll = long long;

int main(){

    ll N, ans=0;
    cin >> N;

    vector<ll> A(N);
    for (int i=0; i<N; i++) cin >> A[i];
    sort(A.begin(), A.end());
    vector<vector<vector<ll>>> dp(N+1, vector(N+1, vector<ll>(5001)));
    dp[0][0][0] = 1;
    for (int i=1; i<=N; i++){
        for (int j=0; j<=N; j++){
            for (int k=0; k<=5000; k++){
                dp[i][j][k] += dp[i-1][j][k];
                if (j-1>=0 && k-A[i-1]>=0) dp[i][j][k] += dp[i-1][j-1][k-A[i-1]];
            }
        }
    }

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

    cout << ans << endl;

}
0