結果
| 問題 |
No.3214 small square
|
| コンテスト | |
| ユーザー |
Kude
|
| 提出日時 | 2025-07-25 22:53:33 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,138 bytes |
| コンパイル時間 | 3,741 ms |
| コンパイル使用メモリ | 319,700 KB |
| 実行使用メモリ | 16,308 KB |
| 最終ジャッジ日時 | 2025-07-25 22:53:46 |
| 合計ジャッジ時間 | 11,464 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 38 WA * 2 |
ソースコード
#include<bits/stdc++.h>
namespace {
#pragma GCC diagnostic ignored "-Wunused-function"
#include<atcoder/all>
#pragma GCC diagnostic warning "-Wunused-function"
using namespace std;
using namespace atcoder;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(i,n) for(int i = (int)(n) - 1; i >= 0; i--)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }
template<class T> bool chmin(T& a, const T& b) { if (b < a) { a = b; return true; } else return false; }
using ll = long long;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
template <class S>
struct value_compression : vector<S> {
bool built = false;
using VS = vector<S>;
using VS::VS;
value_compression(vector<S> v) : vector<S>(move(v)) {}
void build() {
sort(this->begin(), this->end());
this->erase(unique(this->begin(), this->end()), this->end());
built = true;
}
template <class T>
void convert(T first, T last) {
assert(built);
for (; first != last; ++first) *first = (*this)(*first);
}
int operator()(S x) {
assert(built);
return lower_bound(this->begin(), this->end(), x) - this->begin();
}
void clear() {
this->clear();
built = false;
}
};
} int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n, a;
cin >> n >> a;
vector<tuple<int, int, int, int>> evs;
value_compression<int> vc;
rep(_, n) {
int x, y, v;
cin >> x >> y >> v;
evs.emplace_back(x-a, 1, y, v);
evs.emplace_back(x+1, -1, y, -v);
vc.emplace_back(y-a);
vc.emplace_back(y+1);
}
vc.build();
constexpr long long INF = 1002003004005006007;
lazy_segtree<ll, [](ll x, ll y) { return max(x, y); }, []() { return -INF; }, ll, [](ll f, ll x) { return f + x; }, [](ll f, ll g) { return f + g; }, []() { return 0; }> seg(VL(vc.size(), 0));
sort(all(evs));
ll ans = 0;
for (auto [x, _, y, v] : evs) {
seg.apply(vc(y-a), vc(y+1), v);
chmax(ans, seg.all_prod());
}
cout << ans << '\n';
}
Kude