#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
using IntPair = pair<int, int>;
int main()
{
int n,sz, mx = 0, mx2 = 0;
cin >> n >> sz;
vector<int> v(n + 1);
IntPair ans;
for (int i = 0; i < sz; i++)
{
int a, b, cnt = 0;
cin >> a >> b;
if (b - a > mx)
{
mx = b - a;
ans.first = i + 1;
}
for (int j = a; j <= b; j++)
{
if (v[j] == 0)
{
v[j] = i + 1;
cnt++;
}
}
if (cnt > mx2)
{
mx2 = cnt;
ans.second = i + 1;
}
cnt = 0;
}
cout << ans.first << '\n' << ans.second;
}
'코딩테스트 > 백준' 카테고리의 다른 글
[브2] 17608 - 막대기 (0) | 2025.01.01 |
---|---|
[실5] 1418 - K-세준수 (0) | 2025.01.01 |
[실4] 2870 - 수학숙제 (0) | 2024.12.29 |
[실5] 7568 - 덩치 (0) | 2024.12.27 |
[실5] 25497 - 기술 연계마스터 임스 (0) | 2024.12.22 |