結果
| 問題 |
No.2852 Yakitori Optimization Problem
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-08-25 18:02:27 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 100 ms / 2,000 ms |
| コード長 | 971 bytes |
| コンパイル時間 | 4,028 ms |
| コンパイル使用メモリ | 148,472 KB |
| 実行使用メモリ | 8,832 KB |
| 最終ジャッジ日時 | 2024-08-25 18:02:35 |
| 合計ジャッジ時間 | 6,794 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 17 |
ソースコード
#pragma GCC optimize("O2")
#ifdef local
#include <C++/core/io/debug_print.hpp>
#else
#define dump(...) void(0);
#endif
#include <iostream>
#include <valarray>
#include <algorithm>
#include <numeric>
#include <ranges>
namespace man {
}
int main() {
std::cin.tie(nullptr) -> sync_with_stdio(false);
int n, k;
std::cin >> n >> k;
std::valarray<int> a(n), b(n), c(n);
for(auto &e: a) {
std::cin >> e;
}
for(auto &e: b) {
std::cin >> e;
}
for(auto &e: c) {
std::cin >> e;
}
std::valarray<int> d = b - c, id(n);
std::iota(std::begin(id), std::end(id), 0);
dump(d);
std::ranges::sort(id, [&](const int i, const int j) -> bool {
return d[i] > d[j];
});
dump(id);
std::valarray<int64_t> ret(n);
for(const auto &i: std::views::iota(0, n)) {
const int j = id[i];
ret[i] = a[j] + (i < k ? b[j] : c[j]);
}
dump(ret);
std::cout << ret.sum() << '\n';
}