結果
| 問題 |
No.704 ゴミ拾い Medium
|
| コンテスト | |
| ユーザー |
lorent_kyopro
|
| 提出日時 | 2021-04-07 00:29:43 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 922 bytes |
| コンパイル時間 | 4,105 ms |
| コンパイル使用メモリ | 199,540 KB |
| 最終ジャッジ日時 | 2025-01-20 12:39:29 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 7 WA * 29 RE * 8 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/segtree>
__attribute__((constructor))
void fast_io() {
std::ios_base::sync_with_stdio(false);
std::cin.tie(nullptr);
}
using S = std::pair<long long, long long>;
S op(S a, S b) {
return {std::min(a.first, b.first), std::min(a.second, b.second)};
}
S e() { return {LLONG_MAX >> 1, LLONG_MAX >> 1}; };
int main() {
size_t n;
std::cin >> n;
std::vector<long long> a(n), x(n), y(n);
for (auto& ai : a) std::cin >> ai;
for (auto& xi : x) std::cin >> xi;
for (auto& yi : y) std::cin >> yi;
long long xmax = *std::max_element(x.begin(), x.end());
atcoder::segtree<S, op, e> seg(xmax + 1);
long long dp = 0;
for (size_t i = 0; i < n; ++i) {
seg.set(x[i], {dp - x[i] + y[i], dp + x[i] + y[i]});
dp = std::min(seg.prod(0, a[i]).first + a[i], seg.prod(a[i], xmax).second - a[i]);
}
std::cout << dp << '\n';
}
lorent_kyopro