結果

問題 No.3219 Ruler to Maximize
ユーザー miho-4
提出日時 2025-08-01 22:30:50
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 70 ms / 2,000 ms
コード長 343 bytes
コンパイル時間 178 ms
コンパイル使用メモリ 82,256 KB
実行使用メモリ 76,364 KB
最終ジャッジ日時 2025-08-01 22:30:56
合計ジャッジ時間 3,860 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

n=int(input())
L=list(map(int,input().split()))

T=0
for e in L:
  T|=e

ans=0
ANS=["W"]*n
for OR in range(2**14):
  B,W=0,0
  TMP=["W"]*n
  
  for i in range(n):
    if OR|L[i]==OR:
      B|=L[i]
      TMP[i]="B"
    else:
      W|=L[i]
  if B==OR and B&W==0:
    if ans<B*W:
      ans=B*W
      ANS=TMP
      
print(ans)
print("".join(ANS))
0