結果
問題 | No.1564 Sum of Products of Pairs |
ユーザー |
|
提出日時 | 2023-02-04 19:07:58 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 778 ms / 2,000 ms |
コード長 | 1,014 bytes |
コンパイル時間 | 2,236 ms |
コンパイル使用メモリ | 79,292 KB |
実行使用メモリ | 58,940 KB |
最終ジャッジ日時 | 2024-07-03 15:47:45 |
合計ジャッジ時間 | 17,083 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 |
ソースコード
import java.util.*;import java.io.*;import java.math.*;import java.util.stream.Stream;public class Main{/* 入出力 */static BufferedReader buff = new BufferedReader(new InputStreamReader(System.in));static StringTokenizer st;static PrintWriter output = new PrintWriter(System.out);static Scanner sc = new Scanner(System.in);/* 定数 */static final int [] y4 = {0,1,0,-1};static final int [] x4 = {1,0,-1,0};static final int INF1 = Integer.MAX_VALUE;static final long INF2 = Long.MAX_VALUE;static final long MOD1 = (long)1e9+7;static final long MOD2 = 998244353;/* Main */public static void main(String[] args) throws IOException{int n = sc.nextInt();int [] A = new int[2*n];for(int i=0;i<2*n;i++) A[i] = sc.nextInt();Arrays.sort(A);long ans = 0;for(int i=0;i<n;i++) {ans += (long)A[2*i]*A[(2*i)+1];}output.print(ans);output.flush();}}