結果

問題 No.2284 Assembly
ユーザー LyricalMaestro
提出日時 2024-02-04 04:26:50
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 197 ms / 2,000 ms
コード長 473 bytes
コンパイル時間 218 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 87,572 KB
最終ジャッジ日時 2024-09-28 11:09:20
合計ジャッジ時間 4,252 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

## https://yukicoder.me/problems/no/2284



def main():
    N = int(input())
    ab = []
    for _ in range(N):
        a, b = map(int, input().split())
        ab.append((a, b))
    
    a_sum = 0
    b_sum = 0

    max_ans = 0
    ab.reverse()
    for a, b in ab:
        ans1 = max_ans + b * a_sum
        ans2 = max_ans + a * b_sum
        max_ans = max(ans1, ans2)
        a_sum += a
        b_sum += b
    print(max_ans)
    




if __name__ == "__main__":
    main()
0