結果

問題 No.1564 Sum of Products of Pairs
ユーザー hatsuka_iwa
提出日時 2021-08-21 20:35:04
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 73 ms / 2,000 ms
コード長 290 bytes
コンパイル時間 1,719 ms
コンパイル使用メモリ 170,764 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-15 11:21:52
合計ジャッジ時間 3,841 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
  int N;
  int64_t sum = 0;
  cin >> N;
  vector<int> A(N * 2);
  for (int &a : A) cin >> a;
  sort(A.begin(), A.end());

  for (int i = 0; i < N * 2 - 1; i += 2)
    sum += (int64_t)A.at(i) * A.at(i + 1);
  cout << sum << endl;
}
0