結果
問題 | No.190 Dry Wet Moist |
ユーザー |
![]() |
提出日時 | 2015-12-20 12:40:50 |
言語 | Python2 (2.7.18) |
結果 |
AC
|
実行時間 | 336 ms / 2,000 ms |
コード長 | 512 bytes |
コンパイル時間 | 532 ms |
コンパイル使用メモリ | 6,912 KB |
実行使用メモリ | 32,472 KB |
最終ジャッジ日時 | 2024-09-17 11:59:46 |
合計ジャッジ時間 | 5,337 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge6 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 28 |
ソースコード
from collections import Counter N = input() D=[];W=[];M=Nd=Nw=0 def solve(A,B,Na,Nb): cnt = inc = 0 for a in A: while inc < Nb and a <= B[inc]: inc+=1 if inc >= Nb:continue cnt+=1;inc+=1 Na -= cnt return cnt + min(Na,M) + max(0,Na-M)/2 for a in map(int,raw_input().split()): if a < 0: D+=[-a];Nd+=1 elif a > 0: W+=[a];Nw+=1 else: M += 1 D.sort(reverse=True) W.sort(reverse=True) Cd = Counter(D) Cw = Counter(W) print solve(D,W,Nd,Nw),solve(W,D,Nw,Nd),M/2+sum(min(v,Cw[k]) for k,v in Cd.iteritems())