// g++ 1.cpp -std=c++17 -O2 -I . #include using namespace std; #include using namespace atcoder; using ll = long long; using ld = long double; using vi = vector; using vvi = vector; using vll = vector; using vvll = vector; using vld = vector; using vvld = vector; using vst = vector; using vvst = vector; #define fi first #define se second #define pb push_back #define eb emplace_back #define pq_big(T) priority_queue,less> #define pq_small(T) priority_queue,greater> #define all(a) a.begin(),a.end() #define rep(i,start,end) for(ll i=start;i<(ll)(end);i++) #define per(i,start,end) for(ll i=start;i>=(ll)(end);i--) #define uniq(a) sort(all(a));a.erase(unique(all(a)),a.end()) // https://judge.yosupo.jp/submission/87787 template class bimap { std::map M_ltor; std::map M_rtol; public: bimap() = default; void insert(L l, R r) { if (auto it = M_ltor.lower_bound(l); it != M_ltor.end() && it->first == l) { R old_r = it->second; M_rtol.erase(old_r); it->second = r; } else { M_ltor.emplace_hint(it, l, r); } if (auto it = M_rtol.lower_bound(r); it != M_rtol.end() && it->first == r) { L old_l = it->second; M_ltor.erase(old_l); it->second = l; } else { M_rtol.emplace_hint(it, r, l); } } void erase_left(L l) { if (auto it = M_ltor.find(l); it != M_ltor.end()) { auto r = it->second; M_rtol.erase(r); M_ltor.erase(it); } } L right_ge(R r) { auto it = M_rtol.lower_bound(r); assert(it != M_rtol.end()); return it->second; } }; template class cht { std::map M_f; bimap M_range; public: cht() = default; void push(I a, I b) { if (M_f.empty()) { auto max = std::numeric_limits::max(); M_f.insert({a, b}); M_range.insert(a, max); return; } if (M_unused(a, b)) { return; } M_remove_unused(a, b); M_insert(a, b); } I min(I x) { I a = M_range.right_ge(x); I b = M_f[a]; return a * x + b; } private: bool M_unused(I a, I b) { auto itl = M_f.lower_bound(a); if (itl == M_f.end()) return false; auto [al, bl] = *itl; if (a == al) return bl <= b; if (itl == M_f.begin()) return false; auto itr = std::prev(itl); auto [ar, br] = *itr; return S_right(al, bl, a, b) >= S_right(a, b, ar, br); } void M_remove_unused(I a, I b) { M_f.erase(a); M_range.erase_left(a); std::vector rm; do { auto itl = M_f.lower_bound(a); if (itl == M_f.end()) break; auto itll = std::next(itl); while (itll != M_f.end()) { auto [all, bll] = *itll; auto [al, bl] = *itl; if (S_right(all, bll, al, bl) >= S_right(al, bl, a, b)) { rm.push_back(al); } else { break; } itl = itll++; } } while (false); do { auto itr = M_f.lower_bound(a); if (itr == M_f.begin()) break; auto itrr = std::prev(itr); while (itrr != M_f.begin()) { itr = itrr--; auto [arr, brr] = *itrr; auto [ar, br] = *itr; if (S_right(a, b, ar, br) >= S_right(ar, br, arr, brr)) { rm.push_back(ar); } else { break; } } } while (false); for (auto ar: rm) { M_f.erase(ar); M_range.erase_left(ar); } } void M_insert(I a, I b) { auto it = M_f.lower_bound(a); if (it != M_f.end()) { auto [al, bl] = *it; M_range.insert(al, S_right(al, bl, a, b)); } if (it != M_f.begin()) { auto [ar, br] = *std::prev(it); M_range.insert(a, S_right(a, b, ar, br)); } else { M_range.insert(a, std::numeric_limits::max()); } M_f.insert({a, b}); } static I S_right(I a, I b, I ar, I br) { return S_div_euclid(br - b, a - ar); } static I S_div_euclid(I num, I den) { if (num % den == 0 || num >= 0) return num / den; return num / den + 1; } }; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); ll a;cin>>a; int q;cin>>q; cht ch; while(q--){ int type;cin>>type; if(type==1){ ll s,t;cin>>s>>t; ll b=a*(s+t); ll c=-a*s*t; ch.push(-b,-c); } else{ ll t;cin>>t; ll g=ch.min(t); cout<