結果
問題 | No.2852 Yakitori Optimization Problem |
ユーザー |
|
提出日時 | 2024-08-25 13:37:22 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 295 ms / 2,000 ms |
コード長 | 645 bytes |
コンパイル時間 | 3,359 ms |
コンパイル使用メモリ | 282,696 KB |
実行使用メモリ | 13,816 KB |
最終ジャッジ日時 | 2024-08-25 13:37:34 |
合計ジャッジ時間 | 8,082 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 17 |
ソースコード
#include <bits/stdc++.h>using namespace std;using ll = long long;int main(){int N, K;cin >> N >> K;vector<ll> A(N);for(int i=0; i<N; i++){cin >> A[i];}vector<ll> B(N);for(int i=0; i<N; i++){cin >> B[i];}vector<ll> C(N);for(int i=0; i<N; i++){cin >> C[i];}priority_queue<pair<ll,int>> que;for(int i=0; i<N; i++){que.emplace(B[i]-C[i], i);}ll ans = 0;for(int i=0; i<N; i++){ans += A[i];}for(int i=0; i<K; i++){auto [d, k] = que.top();que.pop();ans += B[k];}while(!que.empty()){auto [d, k] = que.top();que.pop();ans += C[k];}cout << ans << endl;return 0;}