結果

問題 No.3238 Shadow
ユーザー 沙耶花
提出日時 2025-08-15 21:52:23
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 458 ms / 2,000 ms
コード長 822 bytes
コンパイル時間 3,837 ms
コンパイル使用メモリ 259,608 KB
実行使用メモリ 16,720 KB
最終ジャッジ日時 2025-08-15 21:55:13
合計ジャッジ時間 8,131 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

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 1000000005
#define Inf64 1000000000000000001LL
using P = pair<int,int>;
P op(P a,P b){
	return min(a,b);
}
P e(){
	return {Inf32,Inf32};
}
P X;
bool f(P x){
	return x >= X;
}
int main(){
	int n;
	cin>>n;
	segtree<P,op,e> seg(n);
	rep(i,n){
		int p;
		cin>>p;
		seg.set(i,{p,i});
	}
	while(seg.all_prod() != e()){
		X = e();
		set<int> is;
		int cx = Inf32,cy = Inf32;
		while(true){
			int r = seg.max_right<f>(0);
			if(r==n)break;
			is.insert(r);
			cx = min(cx,seg.get(r).second+1);
			cy = min(cy,seg.get(r).first);
			X = seg.get(r);
		}
		cout<<cx<<' '<<cy<<endl;
		for(int i : is)seg.set(i,{Inf32,Inf32});
	}
}
0