結果

問題 No.2852 Yakitori Optimization Problem
ユーザー hatsuka_iwa
提出日時 2024-08-25 14:01:34
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 288 ms / 2,000 ms
コード長 583 bytes
コンパイル時間 1,924 ms
コンパイル使用メモリ 177,700 KB
実行使用メモリ 7,296 KB
最終ジャッジ日時 2024-08-25 14:01:41
合計ジャッジ時間 6,708 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, K; cin >> N >> K;
  long long Ans = 0;
  vector<int> A(N), B(N), C(N);
  for (int &a : A) cin >> a;
  for (int &b : B) cin >> b;
  for (int &c : C) cin >> c;
  vector<pair<int, int>> P(N);
  for (int i = 0; i < N; i++) {
    P.at(i).first = B.at(i) - C.at(i);
    P.at(i).second = i;
  }
  sort(P.rbegin(), P.rend());
  for (int i = 0; i < K; i++)
    Ans += A.at(P.at(i).second) + B.at(P.at(i).second);
  for (int i = K; i < N; i++)
    Ans += A.at(P.at(i).second) + C.at(P.at(i).second);
  cout << Ans << endl;
}
0