This documentation is automatically generated by online-judge-tools/verification-helper
#define PROBLEM "https://judge.yosupo.jp/problem/aplusb"
#include <array>
#include <cassert>
#include <iostream>
#include "../top_two.hpp"
void test1_top_two_add() {
TopTwo<int, 1000> t;
{
// (1, -inf)
bool f = t.add(1);
assert(f == true and t.a == 1 and t.b == -1000);
}
{
// (1, 1)
bool f = t.add(1);
assert(f == true and t.a == 1 and t.b == 1);
}
{
// (1, 1)
bool f = t.add(0);
assert(f == false and t.a == 1 and t.b == 1);
}
{
// (1, 1)
bool f = t.add(1);
assert(f == false and t.a == 1 and t.b == 1);
}
{
// (2, 1)
bool f = t.add(2);
assert(f == true and t.a == 2 and t.b == 1);
}
{
// (4, 2)
bool f = t.add(4);
assert(f == true and t.a == 4 and t.b == 2);
}
{
// (4, 3)
bool f = t.add(3);
assert(f == true and t.a == 4 and t.b == 3);
}
{
// (4, 3)
bool f = t.add(3);
assert(f == false and t.a == 4 and t.b == 3);
}
}
void test2_top_two_swap() {
TopTwo<int, 1000> t(0, 1);
assert(t.a == 1 and t.b == 0);
}
int main() {
test1_top_two_add();
test2_top_two_swap();
int a, b;
std::cin >> a >> b;
std::cout << a + b << '\n';
return 0;
}#line 1 "misc/test/top_two.test.cpp"
#define PROBLEM "https://judge.yosupo.jp/problem/aplusb"
#include <array>
#include <cassert>
#include <iostream>
#line 2 "misc/top_two.hpp"
template <class T, T inf> struct TopTwo {
T a, b;
TopTwo() {
a = -inf;
b = -inf;
}
TopTwo(T a, T b) : a(a), b(b) {
if (a < b) {
std::swap(this->a, this->b);
}
}
bool add(T x) {
if (a < x) {
b = a;
a = x;
return true;
} else if (b < x) {
b = x;
return true;
}
return false;
}
};
#line 8 "misc/test/top_two.test.cpp"
void test1_top_two_add() {
TopTwo<int, 1000> t;
{
// (1, -inf)
bool f = t.add(1);
assert(f == true and t.a == 1 and t.b == -1000);
}
{
// (1, 1)
bool f = t.add(1);
assert(f == true and t.a == 1 and t.b == 1);
}
{
// (1, 1)
bool f = t.add(0);
assert(f == false and t.a == 1 and t.b == 1);
}
{
// (1, 1)
bool f = t.add(1);
assert(f == false and t.a == 1 and t.b == 1);
}
{
// (2, 1)
bool f = t.add(2);
assert(f == true and t.a == 2 and t.b == 1);
}
{
// (4, 2)
bool f = t.add(4);
assert(f == true and t.a == 4 and t.b == 2);
}
{
// (4, 3)
bool f = t.add(3);
assert(f == true and t.a == 4 and t.b == 3);
}
{
// (4, 3)
bool f = t.add(3);
assert(f == false and t.a == 4 and t.b == 3);
}
}
void test2_top_two_swap() {
TopTwo<int, 1000> t(0, 1);
assert(t.a == 1 and t.b == 0);
}
int main() {
test1_top_two_add();
test2_top_two_swap();
int a, b;
std::cin >> a >> b;
std::cout << a + b << '\n';
return 0;
}