結果

問題 No.1443 Andd
ユーザー chocoruskchocorusk
提出日時 2021-03-26 22:15:34
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 158 ms / 2,000 ms
コード長 1,613 bytes
コンパイル時間 3,724 ms
コンパイル使用メモリ 187,400 KB
実行使用メモリ 43,560 KB
最終ジャッジ日時 2023-08-19 08:41:19
合計ジャッジ時間 5,860 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 6 ms
6,404 KB
testcase_04 AC 10 ms
6,692 KB
testcase_05 AC 7 ms
6,536 KB
testcase_06 AC 6 ms
6,468 KB
testcase_07 AC 9 ms
6,748 KB
testcase_08 AC 8 ms
6,588 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 10 ms
7,056 KB
testcase_11 AC 10 ms
6,740 KB
testcase_12 AC 10 ms
6,736 KB
testcase_13 AC 42 ms
15,040 KB
testcase_14 AC 42 ms
14,992 KB
testcase_15 AC 41 ms
14,948 KB
testcase_16 AC 42 ms
14,976 KB
testcase_17 AC 41 ms
15,180 KB
testcase_18 AC 158 ms
43,560 KB
testcase_19 AC 156 ms
43,452 KB
testcase_20 AC 156 ms
43,464 KB
testcase_21 AC 157 ms
43,540 KB
testcase_22 AC 156 ms
43,552 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#include <atcoder/all>
#define popcount __builtin_popcount
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int, int> P;
bool dp[2][20020][1024];
int main()
{
   int n; cin>>n;
    int a[20020];
    for(int i=0; i<n; i++){
        cin>>a[i];
    }
    const int mask=1023;
    dp[0][0][0]=1;
    for(int i=0; i<n; i++){
        for(int j=0; j<1024; j++){
            dp[1][i+1][(j+a[i])&mask]|=(dp[0][i][j]|dp[1][i][j]);
            dp[0][i+1][j&a[i]]|=(dp[0][i][j]|dp[1][i][j]);
        }
    }
    bool ok[1024]={};
    ok[0]=1;
    int cnt=0;
    for(int i=0; i<n; i++){
        bool ok1[1024]={};
        for(int j=0; j<1024; j++){
            if(ok[j]){
                if(j+a[i]>=1024){
                    cnt++;
                }else{
                    ok1[a[i]+j]=1;
                }
            }
        }
        for(int j=0; j<1024; j++){
            ok[j]=ok1[j];
        }
        int ans=cnt;
        for(int j=0; j<1024; j++){
            if(dp[0][i+1][j]) ok[j]=1;
            if(ok[j]){
                ans++;
                //cout<<j<<" ";
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}
0