結果
問題 |
No.1564 Sum of Products of Pairs
|
ユーザー |
|
提出日時 | 2021-07-02 23:20:01 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 80 ms / 2,000 ms |
コード長 | 379 bytes |
コンパイル時間 | 2,137 ms |
コンパイル使用メモリ | 200,544 KB |
最終ジャッジ日時 | 2025-01-22 16:55:41 |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 |
ソースコード
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; ++i) typedef long long ll; using namespace std; int main() { int N; cin >> N; vector<ll> A(N * 2); rep(i, N * 2) cin >> A[i]; sort(A.rbegin(), A.rend()); ll ans = 0; for (int i = 1; i < N * 2; i += 2) { ans += A[i] * A[i - 1]; } cout << ans << endl; return 0; }