結果

問題 No.1017 Reiwa Sequence
ユーザー 👑 はまやんはまやんはまやんはまやん
提出日時 2020-04-04 17:10:26
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 1,135 ms / 2,000 ms
コード長 2,023 bytes
コンパイル時間 3,982 ms
コンパイル使用メモリ 200,860 KB
実行使用メモリ 146,424 KB
最終ジャッジ日時 2023-09-16 06:01:27
合計ジャッジ時間 33,793 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 55 ms
97,696 KB
testcase_01 AC 67 ms
97,368 KB
testcase_02 AC 57 ms
97,512 KB
testcase_03 AC 57 ms
97,588 KB
testcase_04 AC 57 ms
97,512 KB
testcase_05 AC 57 ms
97,492 KB
testcase_06 AC 57 ms
97,476 KB
testcase_07 AC 58 ms
97,572 KB
testcase_08 AC 56 ms
97,488 KB
testcase_09 AC 59 ms
97,620 KB
testcase_10 AC 205 ms
108,180 KB
testcase_11 AC 59 ms
97,568 KB
testcase_12 AC 1,129 ms
138,688 KB
testcase_13 AC 1,056 ms
138,456 KB
testcase_14 AC 50 ms
97,692 KB
testcase_15 AC 50 ms
97,676 KB
testcase_16 AC 49 ms
97,628 KB
testcase_17 AC 54 ms
98,072 KB
testcase_18 AC 52 ms
97,608 KB
testcase_19 AC 197 ms
113,932 KB
testcase_20 AC 204 ms
113,960 KB
testcase_21 AC 210 ms
113,944 KB
testcase_22 AC 211 ms
114,044 KB
testcase_23 AC 196 ms
113,928 KB
testcase_24 AC 196 ms
113,952 KB
testcase_25 AC 189 ms
113,928 KB
testcase_26 AC 182 ms
113,936 KB
testcase_27 AC 194 ms
114,068 KB
testcase_28 AC 194 ms
114,028 KB
testcase_29 AC 191 ms
113,820 KB
testcase_30 AC 188 ms
113,676 KB
testcase_31 AC 188 ms
112,988 KB
testcase_32 AC 179 ms
112,152 KB
testcase_33 AC 161 ms
110,040 KB
testcase_34 AC 181 ms
110,136 KB
testcase_35 AC 134 ms
110,196 KB
testcase_36 AC 163 ms
109,964 KB
testcase_37 AC 194 ms
112,008 KB
testcase_38 AC 177 ms
112,040 KB
testcase_39 AC 186 ms
112,008 KB
testcase_40 AC 1,134 ms
145,092 KB
testcase_41 AC 1,104 ms
144,404 KB
testcase_42 AC 1,135 ms
146,424 KB
testcase_43 AC 1,107 ms
145,376 KB
testcase_44 AC 371 ms
118,500 KB
testcase_45 AC 1,047 ms
143,496 KB
testcase_46 AC 1,051 ms
143,072 KB
testcase_47 AC 810 ms
140,016 KB
testcase_48 AC 1,058 ms
136,964 KB
testcase_49 AC 383 ms
115,960 KB
testcase_50 AC 398 ms
118,132 KB
testcase_51 AC 54 ms
97,568 KB
testcase_52 AC 219 ms
114,056 KB
testcase_53 AC 183 ms
114,096 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
            ∧_∧
      ∧_∧  (´<_` )  Welcome to My Coding Space!
     ( ´_ゝ`) /  ⌒i     @hamayanhamayan0
    /   \     | |
    /   / ̄ ̄ ̄ ̄/  |
  __(__ニつ/     _/ .| .|____
     \/____/ (u ⊃
---------------------------------------------------------------------------------------------------*/














int N, A[151010];
vector<int> msks[4010101];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;
	rep(i, 0, N) cin >> A[i];

	int M = min(22, N);
	rep(msk, 0, 1 << M) {
		int sm = 0;
		rep(i, 0, M) if (msk & (1 << i)) sm += A[i];
		msks[sm].push_back(msk);
	}

	rep(tot, 1, 4010101) if (1 < msks[tot].size()) {
		int plus = msks[tot][0];
		int minus = msks[tot][1];

		printf("Yes\n");
		rep(i, 0, M) {
			if (i) printf(" ");

			if (plus & (1 << i)) printf("%d", A[i]);
			else if (minus & (1 << i)) printf("-%d", A[i]);
			else printf("0");
		}
		rep(i, M, N) printf(" 0");
		printf("\n");

		return;
	}

	printf("No\n");
}





0