結果

問題 No.1564 Sum of Products of Pairs
ユーザー _umbrella_kasa
提出日時 2021-07-03 09:23:21
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 74 ms / 2,000 ms
コード長 312 bytes
コンパイル時間 1,655 ms
コンパイル使用メモリ 171,276 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-30 02:00:53
合計ジャッジ時間 4,518 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<long int>A(2*N);
    for (int i=0; i<2*N; i++) {
        cin >> A[i];
    }
    sort(A.begin(),A.end());
    long int ans=0;
    for (int i=0; i<2*N; i+=2) {
        ans+=A[i]*A[i+1];
    }
    cout << ans << endl;
}
0