結果

問題 No.3116 More and more teleporter
ユーザー 沙耶花
提出日時 2025-04-18 20:50:44
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 284 ms / 2,000 ms
コード長 694 bytes
コンパイル時間 3,997 ms
コンパイル使用メモリ 252,616 KB
実行使用メモリ 7,888 KB
最終ジャッジ日時 2025-04-18 20:50:52
合計ジャッジ時間 7,769 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 4000000000000000001LL

int op(int a,int b){
	return min(a,b);
}
int e(){
	return Inf32;
}
int main(){
	
	int n,q;
	cin>>n>>q;
	segtree<int,op,e> s0(n),s1(n);
	rep(i,q){
		int t;
		cin>>t;
		if(t==1){
			int x;
			cin>>x;
			x--;
			int ans = x;
			ans = min(ans,s0.prod(0,x)+x);
			ans = min(ans,s1.prod(x,n)-x);
			cout<<ans<<endl;
		}
		else{
			int x,c;
			cin>>x>>c;
			x--;
			s0.set(x,min(s0.get(x),c-x));
			s1.set(x,min(s1.get(x),x+c));
		}
	}
	return 0;
}
0