結果

問題 No.1825 Except One
ユーザー kozykozy
提出日時 2022-01-28 22:24:27
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2,236 ms / 3,000 ms
コード長 921 bytes
コンパイル時間 2,590 ms
コンパイル使用メモリ 208,720 KB
実行使用メモリ 208,448 KB
最終ジャッジ日時 2023-08-30 11:09:41
合計ジャッジ時間 14,309 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1,134 ms
104,164 KB
testcase_04 AC 348 ms
44,716 KB
testcase_05 AC 81 ms
20,540 KB
testcase_06 AC 6 ms
5,736 KB
testcase_07 AC 1,252 ms
99,932 KB
testcase_08 AC 939 ms
102,856 KB
testcase_09 AC 6 ms
5,772 KB
testcase_10 AC 679 ms
76,708 KB
testcase_11 AC 151 ms
23,852 KB
testcase_12 AC 380 ms
52,892 KB
testcase_13 AC 171 ms
33,400 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 4 ms
4,700 KB
testcase_16 AC 5 ms
5,184 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 3 ms
4,380 KB
testcase_20 AC 2 ms
4,508 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 3 ms
4,380 KB
testcase_23 AC 3 ms
4,380 KB
testcase_24 AC 74 ms
20,604 KB
testcase_25 AC 12 ms
7,184 KB
testcase_26 AC 2 ms
4,384 KB
testcase_27 AC 302 ms
34,472 KB
testcase_28 AC 1,288 ms
151,676 KB
testcase_29 AC 14 ms
8,608 KB
testcase_30 AC 7 ms
5,804 KB
testcase_31 AC 56 ms
19,424 KB
testcase_32 AC 1,159 ms
115,520 KB
testcase_33 AC 11 ms
8,604 KB
testcase_34 AC 2,236 ms
208,448 KB
権限があれば一括ダウンロードができます

ソースコード

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<long long>>> dp(N+1,vector<vector<long long>>(mm+1,vector<long long>(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