結果
問題 | No.1564 Sum of Products of Pairs |
ユーザー |
👑 |
提出日時 | 2021-12-30 07:46:21 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 72 ms / 2,000 ms |
コード長 | 373 bytes |
コンパイル時間 | 772 ms |
コンパイル使用メモリ | 74,576 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-05 13:54:01 |
合計ジャッジ時間 | 3,442 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main(){ int n;cin>>n; vector<long long> A(2*n); for(int i = 0; 2*n > i; i++){ cin>>A[i]; } sort(A.begin(),A.end(),greater<long long>()); long long ans = 0; for(int i = 0; n > i; i++){ ans += A[2*i]*A[2*i+1]; } cout << ans << endl; }