結果

問題 No.3254 Xor, Max and Sum
ユーザー titia
提出日時 2025-09-11 02:39:15
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 37 ms / 2,000 ms
コード長 367 bytes
コンパイル時間 746 ms
コンパイル使用メモリ 12,032 KB
実行使用メモリ 10,368 KB
最終ジャッジ日時 2025-09-11 02:39:20
合計ジャッジ時間 4,174 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 48
権限があれば一括ダウンロードができます

ソースコード

diff #

N,M=map(int,input().split())

if N%2==0:
    print(N*M)
    exit()
if N==1:
    print(0)
    exit()

A=[0]*min(50,N)

if len(A)%2==0:
    A.pop()

for i in range(33,-1,-1):
    A.sort()
    count=0

    for j in range(len(A)):
        if A[j]+(1<<i)<=M:
            count+=1

    for j in range(count//2*2):
        A[j]+=(1<<i)

ANS=(N-len(A))*M+sum(A)

print(ANS)

0