結果

問題 No.2062 Sum of Subset mod 999630629
ユーザー 沙耶花沙耶花
提出日時 2022-08-26 23:06:39
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 856 bytes
コンパイル時間 5,690 ms
コンパイル使用メモリ 266,028 KB
実行使用メモリ 15,960 KB
最終ジャッジ日時 2024-04-22 01:10:50
合計ジャッジ時間 10,915 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,812 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 26 ms
6,940 KB
testcase_09 AC 22 ms
6,944 KB
testcase_10 AC 20 ms
6,940 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 17 ms
6,944 KB
testcase_24 AC 17 ms
6,940 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000000
#define Inf64 4000000000000000001

int M = 999630629;
int main() {
	
	int n;
	cin>>n;
	vector<int> a(n);
	int S = 0;
	rep(i,n){
		cin>>a[i];
		S += a[i];
	}
	mint ans;
	if(S < M){
		ans = S;
		ans /= 2;
		ans *= mint(2).pow(n);
	}
	else{
		queue<vector<mint>> Q;
		rep(i,n){
			int t = 10000 - a[i];
			vector<mint> x(t+1,0);
			x[0] = 1;
			x.back() = 1;
			Q.push(x);
		}
		while(Q.size()>=2){
			auto x = Q.front();
			Q.pop();
			auto y = Q.front();
			Q.pop();
			Q.push(convolution(x,y));
		}
		rep(i,Q.front().size()){
			int D = 1000000000 - i;
			D %= M;
			ans += Q.front()[i] * D;
		}
	}
	cout<<ans.val()<<endl;
		
    return 0;
}
0