結果
問題 | No.2284 Assembly |
ユーザー | ks2m |
提出日時 | 2023-04-28 22:22:48 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 374 ms / 2,000 ms |
コード長 | 812 bytes |
コンパイル時間 | 4,457 ms |
コンパイル使用メモリ | 76,148 KB |
実行使用メモリ | 48,760 KB |
最終ジャッジ日時 | 2024-11-17 21:18:28 |
合計ジャッジ時間 | 7,247 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 16 |
ソースコード
import java.io.BufferedReader; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); int[] a = new int[n]; int[] b = new int[n]; for (int i = 0; i < n; i++) { String[] sa = br.readLine().split(" "); a[i] = Integer.parseInt(sa[0]); b[i] = Integer.parseInt(sa[1]); } br.close(); long[] a2 = new long[n + 1]; long[] b2 = new long[n + 1]; for (int i = n - 1; i >= 0; i--) { a2[i] = a2[i + 1] + a[i]; b2[i] = b2[i + 1] + b[i]; } long ans = 0; for (int i = 0; i < n; i++) { long v1 = a[i] * b2[i + 1]; long v2 = b[i] * a2[i + 1]; ans += Math.max(v1, v2); } System.out.println(ans); } }