結果
問題 | No.2852 Yakitori Optimization Problem |
ユーザー |
|
提出日時 | 2024-05-09 22:54:32 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 89 ms / 2,000 ms |
コード長 | 672 bytes |
コンパイル時間 | 1,994 ms |
コンパイル使用メモリ | 202,676 KB |
最終ジャッジ日時 | 2025-02-21 12:05:35 |
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 17 |
ソースコード
#include <bits/stdc++.h>using namespace std;int main(){ios::sync_with_stdio(false);cin.tie(nullptr);int n, k;cin >> n >> k;vector<int> a(n), b(n), c(n);for(int i = 0; i < n; i++) cin >> a[i];for(int i = 0; i < n; i++) cin >> b[i];for(int i = 0; i < n; i++) cin >> c[i];vector<pair<int, int>> p(n);for(int i = 0; i < n; i++) p[i] = {b[i] - c[i], i};sort(p.rbegin(), p.rend());long long ans = 0;for(int i = 0; i < n; i++){int idx = p[i].second;if(i < k){ans += a[idx] + b[idx];}else{ans += a[idx] + c[idx];}}cout << ans << "\n";}