結果

問題 No.1017 Reiwa Sequence
ユーザー 👑 jupirojupiro
提出日時 2020-04-10 21:09:43
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
(最新)
J_TLE  
(最初)
実行時間 -
コード長 1,737 bytes
コンパイル時間 1,055 ms
コンパイル使用メモリ 118,352 KB
実行使用メモリ 130,256 KB
最終ジャッジ日時 2023-09-16 07:08:40
合計ジャッジ時間 26,539 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
80,884 KB
testcase_01 AC 40 ms
80,776 KB
testcase_02 AC 32 ms
80,740 KB
testcase_03 AC 34 ms
80,808 KB
testcase_04 AC 33 ms
80,848 KB
testcase_05 AC 33 ms
80,944 KB
testcase_06 AC 33 ms
80,812 KB
testcase_07 AC 32 ms
80,772 KB
testcase_08 AC 33 ms
80,776 KB
testcase_09 AC 34 ms
80,940 KB
testcase_10 AC 163 ms
91,676 KB
testcase_11 AC 35 ms
80,920 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 41 ms
80,840 KB
testcase_15 AC 41 ms
80,984 KB
testcase_16 AC 40 ms
81,008 KB
testcase_17 AC 43 ms
81,340 KB
testcase_18 AC 41 ms
80,860 KB
testcase_19 AC 177 ms
97,160 KB
testcase_20 AC 186 ms
97,156 KB
testcase_21 AC 186 ms
97,156 KB
testcase_22 AC 190 ms
97,272 KB
testcase_23 AC 179 ms
97,188 KB
testcase_24 AC 177 ms
97,180 KB
testcase_25 AC 172 ms
97,240 KB
testcase_26 AC 165 ms
97,212 KB
testcase_27 AC 176 ms
97,220 KB
testcase_28 AC 168 ms
97,080 KB
testcase_29 AC 174 ms
96,920 KB
testcase_30 AC 171 ms
96,784 KB
testcase_31 AC 168 ms
96,080 KB
testcase_32 AC 162 ms
95,284 KB
testcase_33 AC 140 ms
93,188 KB
testcase_34 AC 162 ms
93,096 KB
testcase_35 AC 119 ms
93,116 KB
testcase_36 AC 153 ms
93,084 KB
testcase_37 AC 175 ms
95,148 KB
testcase_38 AC 151 ms
95,212 KB
testcase_39 AC 168 ms
95,200 KB
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 AC 41 ms
80,736 KB
testcase_52 AC 174 ms
97,332 KB
testcase_53 AC 152 ms
97,200 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1 << 28;
constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;

constexpr int mx = 150000 * 22 + 1;
vector<int> dp[mx];
int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/
	ll n; scanf("%lld", &n);
	vector<ll> a(n); for (int i = 0; i < n; i++) scanf("%lld", &a[i]);
	vector<int> res(n);
	if (n > 22) a.resize(22);
	n = a.size();
	for (int S = 0; S < (1 << n); S++) {
		int sum = 0;
		for (int i = 0; i < n; i++) {
			if (S >> i & 1) sum += a[i];
		}
		dp[sum].push_back(S);
	}
	for (int i = 0; i < mx; i++) if (dp[i].size() >= 2) {
		int S1 = dp[i][0];
		int S2 = dp[i][1];
		puts("Yes");
		for (int i = 0; i < n; i++) {
			if (S1 >> i & 1) {
				res[i] = a[i];
			}
			if (S2 >> i & 1) {
				res[i] = -a[i];
			}
		}
		for (int i = 0; i < res.size(); i++) {
			cout << res[i];
			if (i == n - 1) cout << "\n";
			else cout << " ";
		}
		return 0;
	}
	puts("No");
	return 0;
}
0