結果

問題 No.1825 Except One
ユーザー kozykozy
提出日時 2022-01-28 22:22:19
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 903 bytes
コンパイル時間 2,270 ms
コンパイル使用メモリ 207,376 KB
実行使用メモリ 105,820 KB
最終ジャッジ日時 2023-08-28 20:26:51
合計ジャッジ時間 15,142 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1,361 ms
53,648 KB
testcase_04 AC 334 ms
23,872 KB
testcase_05 AC 81 ms
11,840 KB
testcase_06 AC 6 ms
4,496 KB
testcase_07 AC 995 ms
51,272 KB
testcase_08 AC 895 ms
52,900 KB
testcase_09 AC 5 ms
4,384 KB
testcase_10 AC 626 ms
40,088 KB
testcase_11 AC 145 ms
13,636 KB
testcase_12 AC 461 ms
28,112 KB
testcase_13 AC 148 ms
18,440 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 4 ms
4,380 KB
testcase_16 AC 5 ms
4,500 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 3 ms
4,380 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 3 ms
4,380 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 104 ms
11,840 KB
testcase_25 AC 17 ms
5,200 KB
testcase_26 AC 3 ms
4,376 KB
testcase_27 AC 387 ms
18,876 KB
testcase_28 WA -
testcase_29 AC 14 ms
5,864 KB
testcase_30 AC 7 ms
4,620 KB
testcase_31 AC 57 ms
11,316 KB
testcase_32 AC 1,106 ms
59,236 KB
testcase_33 AC 12 ms
5,824 KB
testcase_34 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int> A;
  int mm=0;
  int ss=0;
  for (int i=0; i<N; i++){
    int a;
    cin>>a;
    mm=max(mm,a);
    ss+=a;
    A.push_back(a);
  }
  vector<vector<vector<int>>> dp(N+1,vector<vector<int>>(mm+1,vector<int>(ss+1,0)));
  dp[1][A[0]][A[0]]=1;
  dp[0][0][0]=1;
  long long ans=0;
  int thi=A[0];
  for (int i=1; i<N; i++){
    thi+=A[i];
    for (int j=N; j>=1;j--){
      for (int s=thi; s>=A[i]; s--){
        for (int d=0; d<=A[i]; d++){
          dp[j][A[i]][s]+=dp[j-1][d][s-A[i]];
        }
        for (int d=A[i]+1; d<=mm; d++){
          dp[j][d][s]+=dp[j-1][d][s-A[i]];
        }
      }
    }
  }
  for (int j=2; j<=N; j++){
    for (int k=0; k<=mm; k++){
      for (int s=0; s<=ss; s++){
        if ((s%(j-1)==0) && (k<=s/(j-1))){
          ans+=dp[j][k][s];
        }
      }
    }
  }
  cout<<ans<<endl;
}
0