結果

問題 No.2852 Yakitori Optimization Problem
ユーザー テナガザル
提出日時 2024-08-25 13:37:01
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 263 ms / 2,000 ms
コード長 612 bytes
コンパイル時間 1,166 ms
コンパイル使用メモリ 105,824 KB
実行使用メモリ 7,168 KB
最終ジャッジ日時 2024-08-25 13:37:19
合計ジャッジ時間 5,550 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
  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>> vp(n);
  long long ans = 0;
  for (int i = 0; i < n; ++i) ans += a[i];
  for (int i = 0; i < n; ++i) vp[i] = {b[i] - c[i], c[i]};
  sort(vp.rbegin(), vp.rend());
  for (int i = 0; i < k; ++i) ans += vp[i].first + vp[i].second;
  for (int i = k; i < n; ++i) ans += vp[i].second;
  cout << ans << endl;
}
0