結果
| 問題 | No.2856 Junk Market Game |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-08-25 14:39:12 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 24 ms / 2,000 ms |
| コード長 | 789 bytes |
| 記録 | |
| コンパイル時間 | 1,097 ms |
| コンパイル使用メモリ | 217,512 KB |
| 実行使用メモリ | 16,256 KB |
| 最終ジャッジ日時 | 2026-07-05 12:54:34 |
| 合計ジャッジ時間 | 4,008 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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;
}