結果

問題 No.2856 Junk Market Game
ユーザー tottoripaper
提出日時 2024-08-27 16:31:25
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 18 ms / 2,000 ms
コード長 656 bytes
コンパイル時間 3,252 ms
コンパイル使用メモリ 198,952 KB
最終ジャッジ日時 2025-02-24 02:32:11
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 52
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using ll = std::int64_t;
using T = std::tuple<int, int, int>;

int main(){
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    int N;
    std::cin >> N;

    std::vector<int> A(N * 2), B(N * 2);
    for(int i=0;i<N*2;i++){
        std::cin >> A[i];
    }
    for(int i=0;i<N*2;i++){
        std::cin >> B[i];
    }

    ll res = -std::accumulate(std::begin(B), std::end(B), 0ll);
    std::vector<int> C(N * 2);
    for(int i=0;i<N*2;i++){
        C[i] = A[i] + B[i];
    }
    std::sort(std::begin(C), std::end(C));

    for(int i=0;i<N;i++){
        res += C[i * 2];
    }

    std::cout << res << std::endl;
}
0