結果

問題 No.2221 Set X
ユーザー とりゐとりゐ
提出日時 2023-02-17 22:01:17
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 547 bytes
コンパイル時間 483 ms
コンパイル使用メモリ 86,796 KB
実行使用メモリ 91,168 KB
最終ジャッジ日時 2023-09-26 19:18:53
合計ジャッジ時間 26,626 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
75,128 KB
testcase_01 AC 72 ms
74,976 KB
testcase_02 AC 74 ms
75,312 KB
testcase_03 AC 70 ms
71,028 KB
testcase_04 AC 72 ms
75,060 KB
testcase_05 AC 73 ms
71,108 KB
testcase_06 AC 77 ms
75,316 KB
testcase_07 AC 75 ms
74,980 KB
testcase_08 WA -
testcase_09 AC 77 ms
75,136 KB
testcase_10 WA -
testcase_11 AC 78 ms
75,308 KB
testcase_12 AC 79 ms
75,224 KB
testcase_13 AC 80 ms
75,200 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 478 ms
81,832 KB
testcase_22 AC 560 ms
85,580 KB
testcase_23 AC 113 ms
75,952 KB
testcase_24 AC 461 ms
81,816 KB
testcase_25 AC 316 ms
78,864 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 1,197 ms
90,632 KB
testcase_33 AC 1,032 ms
91,168 KB
testcase_34 AC 1,049 ms
90,680 KB
testcase_35 AC 1,172 ms
91,036 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

def divisors(n):
  lower,upper=[],[]
  i=1
  while i*i<=n:
    if n%i==0:
      lower.append(i)
      if i!=n//i:
        upper.append(n//i)
    i+=1
  return lower+upper[::-1]

def solve(a):
  ans=10**9
  ans2=-1
  kouho=list(range(1,500))+divisors(a[-1])
  kouho.sort()
  for x in kouho:
    last=-1
    cnt=0
    for i in a:
      if i//x!=last:
        cnt+=1
        last=i//x
    if ans>cnt*(x+1):
      ans=cnt*(x+1)
      ans2=x
  
  return ans,ans2

n=int(input())
a=list(map(int,input().split()))
ans,ans2=solve(a)
print(ans2)
print(ans)
0