結果

問題 No.190 Dry Wet Moist
ユーザー rpy3cpp
提出日時 2015-04-22 11:08:04
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 828 bytes
コンパイル時間 114 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 30,552 KB
最終ジャッジ日時 2024-07-05 00:08:25
合計ジャッジ時間 3,352 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 1
other AC * 4 WA * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

def find_max_moist(Ap, Am, np, nm, n0):
    c = p = m = 0
    while p < np and m < nm:
        if Ap[p] == Am[m]:
            c += 1
            p += 1
            m += 1
        elif Ap[p] < Am[m]:
            m += 1
        else:
            p += 1
    return c + n0 // 2


def find_max_wet(Ap, Ar, np, nr):
    c = p = r = 0
    while p < np and r < nr:
        if Ap[p] < Ar[r]:
            c += 1
            p += 1
        r += 1
    return c + max((np - p) // 2, 0)


N = int(input())
As = list(map(int, input().split()))
Ap = [-a for a in As if a > 0]
Am = [a for a in As if a < 0]
Ap.reverse()
Am.reverse()
np = len(Ap)
nm = len(Am)
n0 = 2 * N - np - nm
A0 = [0] * n0
dry = find_max_wet(Am, Ap+A0, nm, np + n0)
wet = find_max_wet(Ap, Am+A0, np, nm + n0)
moist = find_max_moist(Ap, Am, np, nm, n0)
print(dry, wet, moist)
0