結果
問題 | No.2852 Yakitori Optimization Problem |
ユーザー |
![]() |
提出日時 | 2024-08-25 13:36:34 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 290 ms / 2,000 ms |
コード長 | 699 bytes |
コンパイル時間 | 2,102 ms |
コンパイル使用メモリ | 200,992 KB |
最終ジャッジ日時 | 2025-02-24 00:50:15 |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 17 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; int main(void) { int n,k; cin >> n >> k; vector<ll> a(n); vector<ll> b(n); vector<ll> 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]; // aは総和で良い // bとcはどちらを選ぶか // 差が大事 ll ans = accumulate(a.begin(),a.end(),0ll) + accumulate(c.begin(),c.end(),0ll); vector<ll> d(n); for (int i = 0; i < n; i++) d[i] = b[i]-c[i]; sort(d.rbegin(),d.rend()); for (int i = 0; i < k; i++) { ans += d[i]; } cout << ans << endl; return 0; }