結果

問題 No.771 しおり
コンテスト
ユーザー Mcpu3
提出日時 2018-12-25 17:52:02
言語 C++14
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 535 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 433 ms
コンパイル使用メモリ 90,812 KB
実行使用メモリ 9,792 KB
最終ジャッジ日時 2026-09-07 13:27:45
合計ジャッジ時間 2,500 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 26 WA * 17
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <algorithm>
#include <iostream>
#include <utility>
#include <vector>
using namespace std;

bool comp(const pair<int, int> a, const pair<int, int> b) {
	return 2 * a.first - a.second > 2 * b.first - b.second;
}

int main() {
	int ans = 0;
	size_t N;
	cin >> N;
	vector<pair<int, int>> AB(N);
	for (size_t i = 0; i < N; ++i) cin >> AB[i].first >> AB[i].second;
	sort(AB.begin(), AB.end(), comp);
	for (size_t i = 1; i < N; ++i) ans = max(ans, AB[i - 1].second - AB[i - 1].first + AB[i].first);
	cout << ans;
}
0