結果
| 問題 |
No.2221 Set X
|
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2023-02-19 00:55:33 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 807 bytes |
| コンパイル時間 | 146 ms |
| コンパイル使用メモリ | 81,864 KB |
| 実行使用メモリ | 88,508 KB |
| 最終ジャッジ日時 | 2024-07-20 06:47:17 |
| 合計ジャッジ時間 | 6,650 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 18 TLE * 1 -- * 21 |
ソースコード
def calc(x):
score=1
for i in range(1,N):
if A[i]//x!=A[i-1]//x:
score+=1
return score*(x+1)
def calc2(x):
score=1
now=A[0]//x
OK=0
while True:
NG=len(A)
while NG>OK+1:
mid=(OK+NG)//2
if A[mid]//x==now:
OK=mid
else:
NG=mid
if NG==len(A):
break
else:
score+=1
now=A[NG]//x
OK=NG
return score*(x+1)
N=int(input())
A=list(map(int,input().split()))
ANS=1<<100
IND=-1
for i in range(1,100):
k=calc(i)
if k<ANS:
ANS=k
IND=i
for i in range(100,ANS+1):
k=calc2(i)
if k<ANS:
ANS=k
IND=i
if i>ANS:
break
print(IND)
print(ANS)
titia