結果
問題 | No.2856 Junk Market Game |
ユーザー |
|
提出日時 | 2024-08-25 14:39:12 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 36 ms / 2,000 ms |
コード長 | 789 bytes |
コンパイル時間 | 2,129 ms |
コンパイル使用メモリ | 197,344 KB |
最終ジャッジ日時 | 2025-02-24 01:12:43 |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 52 |
ソースコード
#include <bits/stdc++.h>using namespace std;int main() {ios_base::sync_with_stdio(false);cin.tie(nullptr);int N; cin >> N;N *= 2;vector<int> A(N),B(N);for(auto &a : A) cin >> a;for(auto &b : B) cin >> b;vector<bool> already(N);long long answer = 0;for(int i=0; i<N/2; i++){long long now = 1e18,pos = -1;for(int k=0; k<N; k++) if(!already.at(k)){if(now > A.at(k)+B.at(k)) now = A.at(k)+B.at(k),pos = k;}already.at(pos) = true; answer += A.at(pos);now = 1e18;for(int k=0; k<N; k++) if(!already.at(k)){if(now > A.at(k)+B.at(k)) now = A.at(k)+B.at(k),pos = k;}already.at(pos) = true; answer -= B.at(pos);}cout << answer << endl;}