結果

問題 No.3116 More and more teleporter
ユーザー tails
提出日時 2025-04-20 01:04:15
言語 cLay
(20241019-1)
結果
AC  
実行時間 17 ms / 2,000 ms
コード長 464 bytes
コンパイル時間 2,745 ms
コンパイル使用メモリ 192,272 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2025-04-20 01:04:19
合計ジャッジ時間 3,411 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

map<ll,ll>a,b;
ll@n,@q;
a[-1]=0;
b[n]=n;
rep(q){
	ll@t,@x;
	auto i=a.lower_bound(-x);
	auto j=b.lower_bound(x);
	ll u=min(i->first+x+i->second,j->first-x+j->second);
	if(t==1){
		wt(u);
	}
	if(t==2){
		ll@c;
		if(c<u){
			while(i!=a.begin()){
				--i;
				if(i->second<-x-i->first+c){
					break;
				}
				i=a.erase(i);
			}
			a[-x]=c;
			while(j!=b.begin()){
				--j;
				if(j->second<x-j->first+c){
					break;
				}
				j=b.erase(j);
			}
			b[x]=c;
		}
	}
}
0