結果

問題 No.3797 Express Elevators and Emergency Stairs
コンテスト
ユーザー forest3
提出日時 2026-11-19 13:41:52
言語 C++14
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -fplugin=/usr/lib/yukicoder/noavx512-gcc15.so -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 122 ms / 2,000 ms
+ 634µs
コード長 553 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,179 ms
コンパイル使用メモリ 196,140 KB
実行使用メモリ 9,872 KB
最終ジャッジ日時 2026-11-19 13:41:56
合計ジャッジ時間 4,483 ms
ジャッジサーバーID
(参考情報)
judge4_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
using ll = long long;

int main(){
	int n;
	cin >> n;
	using P = pair<int, int>;
	vector<P> p;
	rep(i, 0, n) {
		int a, b;
		cin >> a >> b;
		p.emplace_back(a, b);
	}
	sort(p.begin(), p.end(), [](P a, P b) {
		if(a.first == b.first) return a.second > b.second;
		return a.first < b.first;
	});
	int now = 1, ans = 1;
	rep(i, 0, n) {
		if(p[i].first <= now) {
			if(now < p[i].second) now = p[i].second;
			ans = max(ans, now);
		}
	}
	cout << ans << endl;
}
0