結果

問題 No.1564 Sum of Products of Pairs
ユーザー maguromaguro
提出日時 2021-04-18 19:15:03
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 70 ms / 2,000 ms
コード長 1,154 bytes
コンパイル時間 1,981 ms
コンパイル使用メモリ 202,856 KB
実行使用メモリ 4,684 KB
最終ジャッジ日時 2023-09-07 16:10:23
合計ジャッジ時間 4,574 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 32 ms
4,376 KB
testcase_04 AC 5 ms
4,376 KB
testcase_05 AC 44 ms
4,380 KB
testcase_06 AC 31 ms
4,380 KB
testcase_07 AC 20 ms
4,376 KB
testcase_08 AC 11 ms
4,376 KB
testcase_09 AC 19 ms
4,380 KB
testcase_10 AC 45 ms
4,380 KB
testcase_11 AC 50 ms
4,380 KB
testcase_12 AC 34 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 69 ms
4,600 KB
testcase_19 AC 66 ms
4,420 KB
testcase_20 AC 67 ms
4,556 KB
testcase_21 AC 68 ms
4,604 KB
testcase_22 AC 63 ms
4,376 KB
testcase_23 AC 69 ms
4,588 KB
testcase_24 AC 68 ms
4,644 KB
testcase_25 AC 69 ms
4,684 KB
testcase_26 AC 70 ms
4,620 KB
testcase_27 AC 69 ms
4,620 KB
testcase_28 AC 1 ms
4,380 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 2 ms
4,380 KB
testcase_31 AC 2 ms
4,380 KB
testcase_32 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 2000000030;
constexpr ll INF= 2000000000000000001;
constexpr ll MOD = 1000000007;
const double PI = 3.14159265358979323846;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;

template<typename T> 
vector<T> make_vector(size_t s) {
    return vector<T>(s);
}

template<typename T,typename... Args>
auto make_vector(size_t s,Args... args) {
    return vector(s,make_vector<T>(args...));
}

template<typename T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}

template<typename T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

ll mod(ll val, ll M) {
    val = val % M;
    if(val < 0) {
        val += M;
    }
    return val;
}

int main() {
    int N;
    cin >> N;
    vector<ll> vec(2 * N);
    for(int i = 0;i < 2 * N;i++) {
        cin >> vec.at(i);
    }
    sort(vec.begin(),vec.end());
    reverse(vec.begin(),vec.end());
    ll ret = 0;
    for(int i = 0;i < N;i++) {
        ret += vec.at(i * 2) * vec.at(i * 2 + 1);
    }
    cout << ret << endl;
}
0