結果
問題 |
No.3219 Ruler to Maximize
|
ユーザー |
![]() |
提出日時 | 2025-08-01 22:46:00 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 468 bytes |
コンパイル時間 | 2,928 ms |
コンパイル使用メモリ | 278,544 KB |
実行使用メモリ | 7,720 KB |
最終ジャッジ日時 | 2025-08-01 22:46:13 |
合計ジャッジ時間 | 3,839 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 32 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<int> A(N); for (int& a : A) cin >> a; int ans = 0; int y = 0; for (int x = 0; x < 4096; x++) { int w = 0, b = 0; for (int a : A) { if ((a|x) == x) w |= a; else b |= a; } if ((w&b) != 0) continue; if (ans < w * b) { ans = w * b; y = x; } } cout << ans << endl; for (int a : A) { if ((a|y) == y) cout << "W"; else cout << "B"; } cout << endl; }