zawatins-library

This documentation is automatically generated by online-judge-tools/verification-helper

View the Project on GitHub zawa-tin/zawatins-library

:heavy_check_mark: test/ABC236-E.test.cpp

Depends on

Code

#define PROBLEM "https://onlinejudge.u-aizu.ac.jp/courses/lesson/2/ITP1/1/ITP1_1_A"

#include "../src/template/binary-search-ld.hpp"
#include "../src/template/binary-search.hpp"

#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <functional>

// const int sup = 1e9 + 10;
// 
// template <class T>
// T maximize(const std::vector<T>& A) {
// 	T s = 0, t = 0;
// 	for (const T& a : A) {
// 		const T u = std::max(s, t) + a;
// 		s = t;
// 		t = u;
// 	}
// 	return std::max(s, t);
// }

int main() {
	// int N; std::cin >> N;
	// std::vector A(N, 0);
	// for (auto& a : A) {
	// 	std::cin >> a;
	// }
	// auto f = [&](long double p) -> bool {
	// 	std::vector B(N, (long double)0.0);
	// 	for (int i = 0 ; i < N ; i++) {
	// 		B[i] = A[i] - p;
	// 	}
	// 	return maximize(B) >= 0.0l;
	// };
	// std::cout << std::fixed << std::setprecision(4);
	// std::cout << zawa::binary_search_ld(1.0l, 1e9 + 1.0l, f) << std::endl;
	// auto g = [&](int p) -> bool {
	// 	std::vector B(N, 0);
	// 	for (int i = 0 ; i < N ; i++) {
	// 		B[i] = (A[i] >= p ? 1 : -1);
	// 	}
	// 	return maximize(B) > 0;
	// };
	// std::cout << zawa::binary_search(1, (int)1e9 + 1, g) << std::endl;
	
	std::cout << "Hello World" << std::endl;
}

/*
 * AtCoder Beginner Contest 236
 * https://atcoder.jp/contests/abc236/submissions/38188196
 */
#line 1 "test/ABC236-E.test.cpp"
#define PROBLEM "https://onlinejudge.u-aizu.ac.jp/courses/lesson/2/ITP1/1/ITP1_1_A"

#line 2 "src/template/binary-search-ld.hpp"

#include <cstddef>

namespace zawa {

template <class T, class F, std::size_t up = 80>
T binary_search_ld(T ok, T ng, const F& f) {
	for (std::size_t _ = 0 ; _ < up ; _++) {
		T mid = (ok + ng) / 2;
		if (f(mid)) {
			ok = mid;
		}
		else {
			ng = mid;
		}
	}
	return ok;
}

}
#line 2 "src/template/binary-search.hpp"

#include <cmath>

namespace zawa {

template <class T, class F>
T binary_search(T ok, T ng, const F& f) {
	while (std::abs(ok - ng) > 1) {
		T mid = ((ok + ng) >> 1);
		if (f(mid)) {
			ok = mid;
		}
		else {
			ng = mid;
		}
	}
	return ok;
}

}
#line 5 "test/ABC236-E.test.cpp"

#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <functional>

// const int sup = 1e9 + 10;
// 
// template <class T>
// T maximize(const std::vector<T>& A) {
// 	T s = 0, t = 0;
// 	for (const T& a : A) {
// 		const T u = std::max(s, t) + a;
// 		s = t;
// 		t = u;
// 	}
// 	return std::max(s, t);
// }

int main() {
	// int N; std::cin >> N;
	// std::vector A(N, 0);
	// for (auto& a : A) {
	// 	std::cin >> a;
	// }
	// auto f = [&](long double p) -> bool {
	// 	std::vector B(N, (long double)0.0);
	// 	for (int i = 0 ; i < N ; i++) {
	// 		B[i] = A[i] - p;
	// 	}
	// 	return maximize(B) >= 0.0l;
	// };
	// std::cout << std::fixed << std::setprecision(4);
	// std::cout << zawa::binary_search_ld(1.0l, 1e9 + 1.0l, f) << std::endl;
	// auto g = [&](int p) -> bool {
	// 	std::vector B(N, 0);
	// 	for (int i = 0 ; i < N ; i++) {
	// 		B[i] = (A[i] >= p ? 1 : -1);
	// 	}
	// 	return maximize(B) > 0;
	// };
	// std::cout << zawa::binary_search(1, (int)1e9 + 1, g) << std::endl;
	
	std::cout << "Hello World" << std::endl;
}

/*
 * AtCoder Beginner Contest 236
 * https://atcoder.jp/contests/abc236/submissions/38188196
 */
Back to top page