Cod sursa(job #2498797)

Utilizator mihnea.anghelMihnea Anghel mihnea.anghel Data 24 noiembrie 2019 14:05:36
Problema Combinari Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.45 kb
#include <iostream>
#include <set>

using namespace std;
int t, n, i, k, T;
int v[100009], fr[100009], w[100009], x, y, mindr, maxst;
set<int> s;
set<int>::iterator it;

int main() {
    for ( cin>>T; T--; ){
        cin>>n;
        cin>>maxst>>mindr;
        for ( i=2; i <= n; i++ ){
            cin>>x>>y;
            mindr = min ( mindr, y);
            maxst = max ( maxst, x );
        }
        cout<<max ( 0, maxst-mindr ) <<"\n";
    }
    return 0;
}