結果
問題 |
No.3214 small square
|
ユーザー |
![]() |
提出日時 | 2025-07-25 22:32:56 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 256 ms / 3,000 ms |
コード長 | 2,835 bytes |
コンパイル時間 | 4,024 ms |
コンパイル使用メモリ | 305,460 KB |
実行使用メモリ | 18,432 KB |
最終ジャッジ日時 | 2025-07-25 22:33:14 |
合計ジャッジ時間 | 11,755 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 40 |
ソースコード
#if __INCLUDE_LEVEL__ == 0 #include __BASE_FILE__ void Solve() { int n; int64_t A; IN(n, A); A *= 2; vector<int64_t> X(n), Y(n), V(n); for (int i : Rep(0, n)) { IN(X[i], Y[i], V[i]); X[i] *= 2, Y[i] *= 2; } vector<int64_t> Ux(n), Uy(n); for (int i : Rep(0, n)) { Ux[i] = V[i] < 0 ? X[i] - A - 1 : X[i]; Uy[i] = V[i] < 0 ? Y[i] - A - 1 : Y[i]; } ranges::sort(Ux); ranges::sort(Uy); vector<vector<tuple<int, int, int64_t>>> events(n + 1); for (int i : Rep(0, n)) { // [X[i] - A, X[i] + 1) int lx = int(ranges::lower_bound(Ux, X[i] - A) - Ux.begin()); int rx = int(ranges::lower_bound(Ux, X[i] + 1) - Ux.begin()); int ly = int(ranges::lower_bound(Uy, Y[i] - A) - Uy.begin()); int ry = int(ranges::lower_bound(Uy, Y[i] + 1) - Uy.begin()); events[lx].emplace_back(ly, ry, V[i]); events[rx].emplace_back(ly, ry, -V[i]); } auto op = [](int64_t a, int64_t b) { return max(a, b); }; auto e = []() { return int64_t(0); }; auto mapping = [](int64_t f, int64_t x) { return f + x; }; auto composition = [](int64_t f, int64_t g) { return f + g; }; auto id = []() { return int64_t(0); }; int64_t ans = 0; atcoder::lazy_segtree<int64_t, op, e, int64_t, mapping, composition, id> seg(n); for (int x : Rep1(0, n)) { for (auto [l, r, v] : events[x]) { seg.apply(l, r, v); } SetMax(ans, seg.all_prod()); } OUT(ans); } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); Solve(); } #elif __INCLUDE_LEVEL__ == 1 #include <bits/stdc++.h> #include <atcoder/lazysegtree.hpp> template <class T> concept MyRange = std::ranges::range<T> && !std::convertible_to<T, std::string_view>; template <class T> concept MyTuple = std::__is_tuple_like<T>::value && !MyRange<T>; namespace std { istream& operator>>(istream& is, MyRange auto&& r) { for (auto&& e : r) is >> e; return is; } istream& operator>>(istream& is, MyTuple auto&& t) { apply([&](auto&... xs) { (is >> ... >> xs); }, t); return is; } ostream& operator<<(ostream& os, MyRange auto&& r) { auto sep = ""; for (auto&& e : r) os << exchange(sep, " ") << e; return os; } ostream& operator<<(ostream& os, MyTuple auto&& t) { auto sep = ""; apply([&](auto&... xs) { ((os << exchange(sep, " ") << xs), ...); }, t); return os; } } // namespace std using namespace std; #define LAMBDA2(x, y, ...) ([&](auto&& x, auto&& y) -> decltype(auto) { return __VA_ARGS__; }) #define Rep(...) [](int l, int r) { return views::iota(min(l, r), r); }(__VA_ARGS__) #define Rep1(...) [](int l, int r) { return Rep(l, r + 1); }(__VA_ARGS__) #define SetMax(...) LAMBDA2(x, y, x < y && (x = y, 1))(__VA_ARGS__) #define IN(...) (cin >> forward_as_tuple(__VA_ARGS__)) #define OUT(...) (cout << forward_as_tuple(__VA_ARGS__) << '\n') #endif // __INCLUDE_LEVEL__ == 1