結果

問題 No.1825 Except One
ユーザー dekomori_sanaedekomori_sanae
提出日時 2022-01-28 22:49:59
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,709 bytes
コンパイル時間 1,004 ms
コンパイル使用メモリ 90,364 KB
実行使用メモリ 104,720 KB
最終ジャッジ日時 2023-10-22 04:44:54
合計ジャッジ時間 3,509 ms
ジャッジサーバーID
(参考情報)
judge10 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
9,812 KB
testcase_01 AC 2 ms
9,812 KB
testcase_02 AC 3 ms
13,908 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 2 ms
7,764 KB
testcase_15 WA -
testcase_16 AC 4 ms
15,956 KB
testcase_17 AC 3 ms
9,812 KB
testcase_18 AC 2 ms
7,764 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 3 ms
11,860 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 998244353;
const ll INF = 1e16;

ll dp[51][51][5001];  // dp[i][j][k] : i項目までで、j個選んで、総和がkとなる場合の数
  
int main() {
    ll n;
    cin >> n;

    vl a(n);
    rep(i, n) {
        cin >> a[i];
    }
    sort(all(a));
    
    dp[0][0][0] = 1;
    rep(i, n) {
        exrep(j, 0, n-1) {
            exrep(k, 0, 100*n) {
                // a[i]を選ばないとき
                dp[i+1][j][k] += dp[i][j][k];
                // a[i]を選ぶとき
                if(k + a[i] <= 100*n) {
                    dp[i+1][j+1][k + a[i]] += dp[i][j][k];
                }
            }
        }
    }
    
    ll ans = n * (n - 1) / 2;
    exrep(i, 2, n-1) {  // a[i]を末尾の要素とする
        exrep(j, 2, n-1) {
            exrep(k, 0, 100*n) {
                if((j - 1) * a[i] <= k && k % j == 0) {
                    ans += dp[i][j][k];
                }
            }
        }
    }

    out(ans);
    re0;
}
0