結果

問題 No.1645 AB's abs
ユーザー hamihami
提出日時 2021-11-26 17:58:57
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 824 bytes
コンパイル時間 1,613 ms
コンパイル使用メモリ 170,292 KB
実行使用メモリ 814,692 KB
最終ジャッジ日時 2023-09-12 00:48:36
合計ジャッジ時間 4,266 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 MLE -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include<iostream>
using namespace std;
using LL = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
const int INF = 1 << 29;
const long long LINF = 1LL << 60;
#define all(x) (x).begin(), (x).end()
#define rep(i,n) for(int i = 0; i < (n); ++i)
template<class T>void chmin(T&a, T b){if(a > b) a = b;}
template<class T>void chmax(T&a, T b){if(a < b) a = b;}


int main(){
	int N; cin >> N;
	vector<int> A(N); 
	for(int i = 0; i < N; ++i) cin >> A[i];

	vector<int> B;
	B.push_back(A[0]);
	B.push_back(-1*A[0]);
	for(int i = 1; i < N; ++i){
		vector<int> C;
		for(auto v : B){
			C.push_back(v + A[i]);
			C.push_back(v - A[i]);
		}
		B.assign(C.begin(), C.end());
	}
	long long ans = 0;

	for(auto v : B){
	   ans += abs(v);
   	   ans %= 998244353;
	}
	cout << ans << endl;	
	
}

0