cp-library

競技プログラミング用 C++ ライブラリ

View the Project on GitHub qandori/cp-library

:heavy_check_mark: test/dynamic_li_chao_tree_line.test.cpp

test/dynamic_li_chao_tree_line.test.cpp · GitHub で見る

検証問題

依存ライブラリ

コード

#define PROBLEM "https://judge.yosupo.jp/problem/line_add_get_min"
#include "data_structure/dynamic_li_chao_tree.hpp"
#include "components/fast_io.hpp"

int main() {
	FastInput input;
	FastOutput output;
	int n = 0, q = 0;
	input.read(n), input.read(q);
	DynamicLiChaoTree<> tree(-1000000000LL, 1000000001LL);
	tree.reserve(n + q);
	for (int i = 0; i < n; ++i) {
		std::int64_t a = 0, b = 0;
		input.read(a), input.read(b);
		tree.add_line(a, b);
	}
	while (q--) {
		int type = 0;
		std::int64_t a = 0, b = 0;
		input.read(type), input.read(a);
		if (type == 0) input.read(b), tree.add_line(a, b);
		else output.println(std::int64_t(*tree.query(a)));
	}
}
Back to top page