結果

問題 No.1564 Sum of Products of Pairs
ユーザー oooooba
提出日時 2021-08-07 11:28:02
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 73 ms / 2,000 ms
コード長 617 bytes
コンパイル時間 1,162 ms
コンパイル使用メモリ 118,248 KB
最終ジャッジ日時 2025-01-23 16:38:18
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <array>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <optional>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

int main() {
    int32_t n;
    cin >> n;
    vector<int32_t> as(2 * n);
    for (auto &&a : as) {
        cin >> a;
    }
    sort(as.begin(), as.end());
    int64_t ans = 0;
    for (auto i = 0; i < n; ++i) {
        ans += int64_t(as[i * 2]) * as[i * 2 + 1];
    }
    cout << ans << endl;
    return 0;
}
0