結果

問題 No.1564 Sum of Products of Pairs
ユーザー a01sa01to
提出日時 2024-12-04 00:00:39
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 72 ms / 2,000 ms
コード長 445 bytes
コンパイル時間 3,156 ms
コンパイル使用メモリ 250,136 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-04 00:00:46
合計ジャッジ時間 6,490 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
  #include "settings/debug.cpp"
#else
  #define Debug(...) void(0)
#endif
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using ull = unsigned long long;

int main() {
  int n;
  cin >> n;
  vector<ll> a(n * 2);
  rep(i, 2 * n) cin >> a[i];
  sort(a.begin(), a.end());
  ll ans = 0;
  rep(i, n) ans += a[2 * i] * a[2 * i + 1];
  cout << ans << endl;
  return 0;
}
0