Submission

Status:

[PPP-SSSSSSSSSSSSSSSSSSSSS]

Subtask/Task Score:

{0/100}

Score: 0

User: Test

Problemset: วันว่างๆ

Language: cpp

Time: 0.002 second

Submitted On: 2026-03-04 20:05:40

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

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    vector<pair<int,int>> ev;
    int n,m;
    cin >> n;
    int mx =0;
    for(int ppl=0;ppl<n;ppl++){
        cin >> m;
        for(int i=0;i<m;i++){
            int l,r;
            cin >> l >> r;
            mx = max(mx,max(l,r));
            ev.push_back({l,1});
            ev.push_back({r,-1});
        }
    }

    sort(ev.begin(), ev.end());

    int cur = 0;
    bool have = false;
    for(int i = 0; i < ev.size(); i++){
        cur += ev[i].second;
        if(cur == 0){
            if(have == false && ev[i].first>= mx){
                cout << "-1";
                return 0;
            }
            if(ev[i].first>= mx) return 0;
            cout << ev[i].first << " " << ev[i+1].first << " ";
            have = true;

        }
    }
}