結果

問題 No.3219 Ruler to Maximize
ユーザー timi
提出日時 2025-08-02 15:40:57
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 57 ms / 2,000 ms
コード長 368 bytes
コンパイル時間 716 ms
コンパイル使用メモリ 82,976 KB
実行使用メモリ 67,432 KB
最終ジャッジ日時 2025-08-02 15:41:02
合計ジャッジ時間 4,326 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

N=int(input())
A=list(map(int, input().split()))
d=12
c=pow(2,d)
p=pow(2,d)-1

ma=-1;ans=[]
for i in range(pow(2,d)):
  f=0
  E=[]
  j=p-i;w,b=0,0
  for a in A:
    if i|a==i:
      E.append('W')
      w|=a
    elif j|a==j:
      E.append('B')
      b|=a
    else:
      f=-1
  if f==0 and w&b==0:
    if ma<w*b:
      ma=w*b
      ans=E
print(ma) 
print(''.join(ans))
0