結果
問題 |
No.3219 Ruler to Maximize
|
ユーザー |
![]() |
提出日時 | 2025-06-27 21:13:10 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,165 bytes |
コンパイル時間 | 1,766 ms |
コンパイル使用メモリ | 195,636 KB |
実行使用メモリ | 7,848 KB |
最終ジャッジ日時 | 2025-06-27 21:47:13 |
合計ジャッジ時間 | 2,867 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 22 WA * 10 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int N; cin >> N; vector<int> A(N); for (int i = 0; i < N; i++) { cin >> A[i]; } const int E = 12; const int MASK = 0b111111111111; ll ans = -1; int maxB = 0; for (int b = 0; b < (1 << E); b++) { int w = (~b) & MASK; int blackCount = 0; int whiteCount = 0; int wor = 0; int bor = 0; for (int i = 0; i < N; i++) { if ((w | A[i]) == w) { whiteCount++; wor |= A[i]; } if ((b | A[i]) == b) { blackCount++; bor |= A[i]; } } if (whiteCount + blackCount != N) continue; ll product = (ll)wor * (ll)bor; if (product > ans) { ans = product; maxB = b; } } cout << ans << endl; for (int i = 0; i < N; i++) { cout << (((maxB | A[i]) == maxB) ? "B" : "W"); } cout << endl; }