結果
| 問題 |
No.2852 Yakitori Optimization Problem
|
| コンテスト | |
| ユーザー |
sai
|
| 提出日時 | 2024-08-25 13:41:14 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 93 ms / 2,000 ms |
| コード長 | 857 bytes |
| コンパイル時間 | 2,817 ms |
| コンパイル使用メモリ | 258,760 KB |
| 実行使用メモリ | 11,136 KB |
| 最終ジャッジ日時 | 2024-08-25 13:41:21 |
| 合計ジャッジ時間 | 5,042 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 17 |
ソースコード
#include <bits/stdc++.h>
void solve() {
int N, K; std::cin >> N >> K;
std::vector<long long> A(N), B(N), C(N);
for (auto &a : A) std::cin >> a;
for (auto &b : B) std::cin >> b;
for (auto &c : C) std::cin >> c;
long long ans = 0;
for (auto a : A) ans += a;
std::vector<std::pair<long long, long long>> P(N);
for (int i = 0; i < N; i++) P[i] = std::make_pair(B[i]-C[i], i);
std::sort(P.begin(), P.end(), std::greater<std::pair<long long, long long>>());
std::vector<bool> solt(N, false);
for (int i = 0; i < K; i++) solt[P[i].second] = true;
for (int i = 0; i < N; i++) {
if (solt[i]) ans += B[i];
else ans += C[i];
}
std::cout << ans << std::endl;
}
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int testcases = 1;
//std::cin >> testcases;
for (;testcases--;) solve();
return 0;
}
sai