結果
| 問題 | No.1564 Sum of Products of Pairs | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2021-11-19 15:59:00 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 147 ms / 2,000 ms | 
| コード長 | 344 bytes | 
| コンパイル時間 | 1,949 ms | 
| コンパイル使用メモリ | 198,684 KB | 
| 最終ジャッジ日時 | 2025-01-25 19:34:35 | 
| ジャッジサーバーID (参考情報) | judge4 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 30 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for(int i=0;i<(int)(n);i++)
int main() {
    int N;
    cin >> N;
    vector<int> a(2*N);
    REP(i, 2*N) cin >> a[i];
    sort(a.rbegin(), a.rend());
    ll ans = 0;
    for(int i = 0 ; i < 2*N; i += 2) ans += (ll)a[i] * a[i+1];
    cout << ans << endl;
}
            
            
            
        