結果
| 問題 |
No.2404 Vertical Throw Up
|
| コンテスト | |
| ユーザー |
Haa
|
| 提出日時 | 2023-08-04 22:54:28 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 3,553 bytes |
| コンパイル時間 | 1,532 ms |
| コンパイル使用メモリ | 177,380 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-14 21:02:11 |
| 合計ジャッジ時間 | 3,265 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | WA * 30 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) v.begin(),v.end()
template<typename T> bool chmax(T& x, const T& y){return (x<y)?(x=y,true):false;};
template<typename T> bool chmin(T& x, const T& y){return (x>y)?(x=y,true):false;};
constexpr ll MOD=998244353;
constexpr ll INF=2e18;
int main(){
ll a; cin >> a;
int q; cin >> q;
int idx=0;
vector<P> bc;
set<P> st;
ll r, s, t;
REP(_,q){
cin >> r;
if(r==1){
cin >> s >> t;
ll x=-a*s*s, y=-a*t*t;
ll b=(x-y)/(t-s);
ll c=-(x+b*s);
bc.push_back({b,c});
if(st.empty()){
st.insert({s+t,idx});
idx++;
continue;
}
auto it=st.lower_bound({s+t,0});
bool ok=0;
if(it!=st.end()){
int i=(*it).second;
ll ib=bc[i].first, ic=bc[i].second;
ll m=(s+t)/2;
ll h=-a*m*m+b*m+c;
ll ih=-a*m*m+ib*m+ic;
if(h>ih)
ok=1;
}
if(it!=st.begin()){
int i=(*prev(it)).second;
ll ib=bc[i].first, ic=bc[i].second;
ll m=(s+t+1)/2;
ll h=-a*m*m+b*m+c;
ll ih=-a*m*m+ib*m+ic;
if(h>ih)
ok=1;
}
if(ok){
it=st.lower_bound({s+t,0});
while(it!=st.end()){
int i=(*it).second;
ll ib=bc[i].first, ic=bc[i].second;
ll m=((*it).first)/2;
ll h=-a*m*m+b*m+c;
ll ih=-a*m*m+ib*m+ic;
it++;
if(h>ih)
st.erase(prev(it));
else
break;
}
it=st.lower_bound({s+t,0});
if(!(st.empty()||it==st.begin())){
it--;
while(1){
int i=(*it).second;
ll ib=bc[i].first, ic=bc[i].second;
ll m=((*it).first+1)/2;
ll h=-a*m*m+b*m+c;
ll ih=-a*m*m+ib*m+ic;
if(it==st.begin()){
if(h>ih)
st.erase(it);
break;
}
else{
it--;
if(h>ih)
st.erase(next(it));
else
break;
}
}
}
st.insert({s+t,idx});
}
idx++;
}
else{
cin >> t;
auto it=st.lower_bound({t+t,0});
ll ans=0;
if(it!=st.end()){
int i=(*it).second;
ll ib=bc[i].first, ic=bc[i].second;
ll ih=-a*t*t+ib*t+ic;
chmax(ans,ih);
}
if(it!=st.begin()){
int i=(*prev(it)).second;
ll ib=bc[i].first, ic=bc[i].second;
ll ih=-a*t*t+ib*t+ic;
chmax(ans,ih);
}
cout << ans << endl;
}
}
return 0;
}
Haa