結果

問題 No.1443 Andd
ユーザー SSRSSSRS
提出日時 2021-03-26 21:58:36
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 756 bytes
コンパイル時間 1,900 ms
コンパイル使用メモリ 177,988 KB
実行使用メモリ 450,716 KB
最終ジャッジ日時 2024-05-06 15:28:59
合計ジャッジ時間 10,887 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
13,760 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,944 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 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 TLE -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++){
    cin >> A[i];
  }
  vector<vector<bool>> dp(N + 1, vector<bool>(1 << 10, false));
  dp[0][0] = true;
  for (int i = 0; i < N; i++){
    for (int j = 0; j < (1 << 10); j++){
      if (dp[i][j]){
        dp[i + 1][(j + A[i]) % (1 << 10)] = true;
        dp[i + 1][j & A[i]] = true;
      }
    }
  }
  long long sum = 0;
  for (int i = 0; i < N; i++){
    sum += A[i];
  }
  set<int> st;
  for (int i = 0; i <= N; i++){
    for (int j = 0; j < (1 << 10); j++){
      if (dp[i][j]){
        st.insert(sum + j);
      }
    }
    if (i < N){
      sum -= A[i];
    }
    if (i > 0){
      cout << st.size() << endl;
    }
  }
}
0