結果

問題 No.2284 Assembly
ユーザー LyricalMaestroLyricalMaestro
提出日時 2024-02-04 04:26:50
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 186 ms / 2,000 ms
コード長 473 bytes
コンパイル時間 330 ms
コンパイル使用メモリ 81,572 KB
実行使用メモリ 87,356 KB
最終ジャッジ日時 2024-02-04 04:26:55
合計ジャッジ時間 4,766 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,460 KB
testcase_01 AC 35 ms
53,460 KB
testcase_02 AC 36 ms
53,460 KB
testcase_03 AC 37 ms
53,460 KB
testcase_04 AC 36 ms
53,460 KB
testcase_05 AC 36 ms
53,460 KB
testcase_06 AC 37 ms
53,460 KB
testcase_07 AC 36 ms
53,460 KB
testcase_08 AC 186 ms
87,152 KB
testcase_09 AC 182 ms
87,156 KB
testcase_10 AC 181 ms
87,156 KB
testcase_11 AC 181 ms
87,156 KB
testcase_12 AC 180 ms
87,156 KB
testcase_13 AC 181 ms
87,156 KB
testcase_14 AC 182 ms
87,152 KB
testcase_15 AC 182 ms
87,156 KB
testcase_16 AC 185 ms
87,156 KB
testcase_17 AC 182 ms
87,156 KB
testcase_18 AC 178 ms
87,356 KB
権限があれば一括ダウンロードができます

ソースコード

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