結果
| 問題 | No.2404 Vertical Throw Up |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-09-09 13:21:27 |
| 言語 | C++23 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 13 ms / 2,000 ms |
| + 858µs | |
| コード長 | 1,934 bytes |
| 記録 | |
| コンパイル時間 | 2,610 ms |
| コンパイル使用メモリ | 337,612 KB |
| 実行使用メモリ | 6,528 KB |
| 最終ジャッジ日時 | 2026-09-09 13:21:35 |
| 合計ジャッジ時間 | 5,327 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 30 |
ソースコード
#include <bits/stdc++.h>
using i64 = long long;
using u64 = unsigned long long;
using u32 = unsigned;
using u128 = unsigned __int128;
using i128 = __int128;
bool check(i64 a1, i64 b1, i64 a2, i64 b2, i64 a3, i64 b3) {
return (i128)(a2 - a1) * (b3 - b2) < (i128)(b2 - b1) * (a3 - a2);
}
void solve() {
i64 a; int Q; std::cin >> a >> Q;
std::set<std::pair<i64, i64>> ch;
while(Q --) {
int q; std::cin >> q;
if(q == 1) {
i64 s, t; std::cin >> s >> t;
std::pair<i64, i64> add = std::make_pair(s + t, - s * t);
auto it = ch.lower_bound(add);
if(it != ch.begin() && it != ch.end()) {
auto it2 = it;
it2 --;
if(!check(it2 -> first, it2 -> second, add.first, add.second, it -> first, it -> second)) continue;
}
it = ch.insert(add).first;
while(1) {
auto it2 = it, it3 = it;
it2 ++; it3 ++;
if(it2 == ch.end()) break;
it3 ++;
if(it3 == ch.end()) break;
if(check(it -> first, it -> second, it2 -> first, it2 -> second, it3 -> first, it3 -> second)) break;
ch.erase(it2);
}
while(1) {
auto it2 = it, it3 = it;
if(it2 == ch.begin()) break;
it2 --; it3 --;
if(it3 == ch.begin()) break;
it3 --;
if(check(it3 -> first, it3 -> second, it2 -> first, it2 -> second, it -> first, it -> second)) break;
ch.erase(it2);
}
} else{
i64 t; std::cin >> t;
while(!ch.empty()) {
auto it = ch.begin();
auto it2 = it;
it2 ++;
if(it2 == ch.end()) break;
if(t * it -> first + it -> second <= t * it2 -> first + it2 -> second) ch.erase(it);
else break;
}
if(ch.empty()) std::cout << 0 << "\n";
else {
auto it = ch.begin();
i64 ans = a * (- t * t + t * it -> first + it -> second);
std::cout << std::max(0LL, ans) << "\n";
}
}
}
}
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int T = 1;
//std::cin >> T;
while (T--) {
solve();
}
return 0;
}