結果

問題 No.190 Dry Wet Moist
ユーザー sasa8uyauyasasa8uyauya
提出日時 2024-11-17 13:54:27
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 200 ms / 2,000 ms
コード長 659 bytes
コンパイル時間 940 ms
コンパイル使用メモリ 82,368 KB
実行使用メモリ 121,588 KB
最終ジャッジ日時 2024-11-17 13:54:33
合計ジャッジ時間 5,826 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve(a1,a2):
  a1.sort()
  a2.sort()
  c=0
  for i in reversed(range(len(a1))):
    while len(a2)>0 and a2[-1]>=a1[i]:
      a2.pop()
    if len(a2)>0:
      c+=1
      a2.pop()
    else:
      c+=(i+1)//2
      break
  return c

n=int(input())
a=list(map(int,input().split()))
ad=solve([abs(a[i]) for i in range(n*2) if a[i]<0],[abs(a[i]) for i in range(n*2) if not a[i]<0])
aw=solve([abs(a[i]) for i in range(n*2) if a[i]>0],[abs(a[i]) for i in range(n*2) if not a[i]>0])
am=0
L=10**5
c1=[0]*(L+1)
c2=[0]*(L+1)
for v in a:
  if v>=0:
    c1[abs(v)]+=1
  else:
    c2[abs(v)]+=1
for i in range(1,L+1):
  am+=min(c1[i],c2[i])
am+=c1[0]//2
print(ad,aw,am)
0