結果
問題 | No.937 Ultra Sword |
ユーザー | vwxyz |
提出日時 | 2023-11-29 19:27:30 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,503 bytes |
コンパイル時間 | 258 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 132,608 KB |
最終ジャッジ日時 | 2024-09-26 13:35:19 |
合計ジャッジ時間 | 23,281 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 162 ms
89,600 KB |
testcase_01 | WA | - |
testcase_02 | AC | 162 ms
89,856 KB |
testcase_03 | AC | 165 ms
89,984 KB |
testcase_04 | AC | 168 ms
90,112 KB |
testcase_05 | AC | 521 ms
132,608 KB |
testcase_06 | AC | 751 ms
122,496 KB |
testcase_07 | AC | 755 ms
122,752 KB |
testcase_08 | AC | 750 ms
119,040 KB |
testcase_09 | AC | 755 ms
118,784 KB |
testcase_10 | AC | 762 ms
125,056 KB |
testcase_11 | AC | 243 ms
95,232 KB |
testcase_12 | AC | 260 ms
105,984 KB |
testcase_13 | AC | 258 ms
105,728 KB |
testcase_14 | AC | 265 ms
107,520 KB |
testcase_15 | AC | 258 ms
102,912 KB |
testcase_16 | AC | 244 ms
94,720 KB |
testcase_17 | AC | 244 ms
94,976 KB |
testcase_18 | AC | 257 ms
104,576 KB |
testcase_19 | AC | 254 ms
99,968 KB |
testcase_20 | AC | 250 ms
98,432 KB |
testcase_21 | AC | 766 ms
124,160 KB |
testcase_22 | AC | 165 ms
89,984 KB |
testcase_23 | AC | 162 ms
89,600 KB |
testcase_24 | AC | 521 ms
126,720 KB |
testcase_25 | AC | 525 ms
121,216 KB |
testcase_26 | AC | 538 ms
119,280 KB |
testcase_27 | AC | 536 ms
120,148 KB |
testcase_28 | AC | 539 ms
120,716 KB |
testcase_29 | AC | 508 ms
116,992 KB |
testcase_30 | AC | 529 ms
117,760 KB |
testcase_31 | AC | 541 ms
122,240 KB |
testcase_32 | AC | 517 ms
116,608 KB |
testcase_33 | AC | 535 ms
122,368 KB |
testcase_34 | AC | 520 ms
115,328 KB |
testcase_35 | AC | 509 ms
115,200 KB |
testcase_36 | AC | 537 ms
120,960 KB |
testcase_37 | AC | 515 ms
115,328 KB |
testcase_38 | AC | 537 ms
120,176 KB |
testcase_39 | AC | 544 ms
116,864 KB |
testcase_40 | AC | 555 ms
120,672 KB |
testcase_41 | AC | 519 ms
115,072 KB |
testcase_42 | AC | 535 ms
117,248 KB |
testcase_43 | AC | 519 ms
117,760 KB |
testcase_44 | AC | 519 ms
115,712 KB |
testcase_45 | AC | 516 ms
116,128 KB |
testcase_46 | AC | 539 ms
116,864 KB |
ソースコード
import bisect import copy import decimal import fractions import heapq import itertools import math import random import sys import time from collections import Counter,deque,defaultdict from functools import lru_cache,reduce from heapq import heappush,heappop,heapify,heappushpop,_heappop_max,_heapify_max def _heappush_max(heap,item): heap.append(item) heapq._siftdown_max(heap, 0, len(heap)-1) def _heappushpop_max(heap, item): if heap and item < heap[0]: item, heap[0] = heap[0], item heapq._siftup_max(heap, 0) return item from math import gcd as GCD read=sys.stdin.read readline=sys.stdin.readline readlines=sys.stdin.readlines write=sys.stdout.write #import pypyjit #pypyjit.set_param('max_unroll_recursion=-1') #sys.set_int_max_str_digits(10**9) def Hadamard(polynomial,n,mod=0,inverse=False): assert mod%2 polynomial_=[x for x in polynomial]+[0]*((1<<n)-len(polynomial)) for bit in range(n): for i in range(1<<n): ii=i^(1<<bit) if i>ii: continue polynomial_[i],polynomial_[ii]=polynomial_[i]+polynomial_[ii],polynomial_[i]-polynomial_[ii] if mod: polynomial_[i]%=mod polynomial_[ii]%=mod if inverse: if mod: inve_2=pow((mod+1)//2,n) for i in range(1<<n): polynomial_[i]*=inve_2 polynomial_[i]%=mod else: pow_2=pow(2,n) for i in range(1<<n): polynomial_[i]/=pow_2 return polynomial_ def XOR_Convolution(polynomial0,polynomial1,mod=0): n=(max(len(polynomial0),len(polynomial1))-1).bit_length() Hadamard_polynomial0=Hadamard(polynomial0,n,mod=mod) Hadamard_polynomial1=Hadamard(polynomial1,n,mod=mod) if mod: convolution=[x*y%mod for x,y in zip(Hadamard_polynomial0,Hadamard_polynomial1)] else: convolution=[x*y for x,y in zip(Hadamard_polynomial0,Hadamard_polynomial1)] convolution=Hadamard(convolution,n,mod=mod,inverse=True) return convolution N=int(readline()) A=list(map(int,readline().split())) max_A=max(A) poly=[0]*(2*max_A+1) poly[0]=1 for a in A: while a<=max_A*2: poly[a]+=1 a*=2 poly=XOR_Convolution(poly,poly,mod=(1<<61)-1) C=[0]*(max_A+1) for a in A: C[a]+=1 sum_A=sum(A) ans=sum_A for i in range(1,max_A+1): if poly[i]==0: continue s=sum_A for j in range(i,max_A+1,i): s-=C[j]*(j-j//i) ans=min(ans,s) print(ans)