結果

問題 No.1825 Except One
ユーザー taisii2taisii2
提出日時 2022-01-29 15:28:03
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 665 bytes
コンパイル時間 1,980 ms
コンパイル使用メモリ 173,904 KB
実行使用メモリ 66,272 KB
最終ジャッジ日時 2023-08-30 14:30:55
合計ジャッジ時間 4,568 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 99 ms
34,200 KB
testcase_04 AC 30 ms
12,608 KB
testcase_05 AC 9 ms
5,964 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 90 ms
31,108 KB
testcase_08 AC 93 ms
32,100 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 62 ms
22,920 KB
testcase_11 AC 13 ms
7,404 KB
testcase_12 AC 35 ms
14,496 KB
testcase_13 AC 18 ms
9,172 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 2 ms
4,384 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 16 ms
8,260 KB
testcase_25 AC 10 ms
6,212 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 62 ms
23,644 KB
testcase_28 WA -
testcase_29 AC 3 ms
4,376 KB
testcase_30 AC 3 ms
4,380 KB
testcase_31 AC 8 ms
5,700 KB
testcase_32 AC 107 ms
38,164 KB
testcase_33 AC 3 ms
4,376 KB
testcase_34 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int>A(N);
  int s=0;
  for(int i=0;i<N;i++){
    cin>>A[i];
    s+=A[i];
  }
  sort(A.begin(),A.end());
  vector<vector<vector<int>>>dp(N+1,vector<vector<int>>(s+1,vector<int>(N+2,0)));
  dp[0][0][0]=1;
  long long ans=0;
  for(int i=0;i<N;i++){
    for(int j=0;j<=s;j++){
      for(int k=0;k<=N;k++){
        dp[i+1][j][k]+=dp[i][j][k];
        if(j+A[i]<=s){
          dp[i+1][j+A[i]][k+1]+=dp[i][j][k];
          long long idx=j-(k-1)*A[i];
          if(k==1||(k>1&&idx>=0&&idx%k==0)){
            ans+=dp[i][j][k];
          }
        }
      }
    }
  }
  cout<<ans<<endl;
}
0