結果

問題 No.3238 Shadow
ユーザー ルビサファせだい
提出日時 2025-08-18 23:45:34
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 338 ms / 2,000 ms
コード長 1,248 bytes
コンパイル時間 4,068 ms
コンパイル使用メモリ 255,764 KB
実行使用メモリ 14,512 KB
最終ジャッジ日時 2025-08-18 23:45:43
合計ジャッジ時間 8,289 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#include <atcoder/all>

using namespace std;
using ll = long long;
using ull = unsigned long long;
template <class T>
using max_heap = priority_queue<T>;
template <class T>
using min_heap = priority_queue<T, vector<T>, greater<>>;
ll ll_min = numeric_limits<ll>::min();
ll ll_max = numeric_limits<ll>::max();
ll ALPHABET_N = 26;
static const ll INF = ll_max / 10;
#define rep(i, n) for (ll i = (ll)0; i < (ll)n; i++)
#define rep_(i, k, n) for (ll i = (ll)k; i < (ll)n; i++)
#define all(a) a.begin(), a.end()
using namespace atcoder;

struct Node
{
	ll idx;
	ll y;
};

Node op(const Node a, const Node b)
{
	if (a.y < b.y)
	{
		return a;
	}
	else
	{
		return b;
	}
}

Node e()
{
	return {-1, ll_max};
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin >> n;
	segtree<Node, op, e> seg(n);
	rep(i, n)
	{
		ll y;
		cin >> y;
		seg.set(i, {i, y});
	}
	while (seg.all_prod().y < ll_max)
	{
		ll x_min = ll_max, y_min = ll_max;
		ll r = n;
		while (true)
		{
			Node node = seg.prod(0, r);
			if (node.y == ll_max)
			{
				break;
			}
			x_min = min(x_min, node.idx + 1);
			y_min = min(y_min, node.y);
			r = node.idx;
			seg.set(node.idx, e());
		}
		cout << x_min << " " << y_min << endl;
	}
	return 0;
}
0