Submission

Status:

PP--PPPP--

Subtask/Task Score:

60/100

Score: 60

User: dddrrrr

Problemset: ไฟส่อง

Language: cpp

Time: 0.002 second

Submitted On: 2025-10-17 18:18:06

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

int main(){
	cin.tie(0)->sync_with_stdio(0);
	cout.tie(0)->sync_with_stdio(0);
	
	int n;
	cin >> n;
	
	vector <pair <int ,int>> vec;
	for(int i=0 ;i<n ;i++){
		int x ,y;
		cin >> x >> y;
		if(x < y)vec.emplace_back(x ,y);
		else vec.emplace_back(x ,360+y);
	}
	
	sort(vec.begin() ,vec.end());
//	for(auto i : vec)cout << i.first << ' ' << i.second << "\n";
//	cout << "\n";
	
	int l = vec[0].first ,r=vec[0].second ,mx=0;
	
	for(int i=1 ;i<n ;i++){
//		cout << l << ' ' << r;
//		cout << "\n";
		if(r >= vec[i].first)r = max(vec[i].second ,vec[i-1].second);
		else{
			mx = max(mx ,r - l);
			l = vec[i].first;
			r = vec[i].second;
		}

	}
	//cout << l << ' ' << r << "\n";
	mx = max(mx ,r-l);
	mx = mx>360 ?360 : mx;
	cout << mx;
	
	
	return 0;
}