#include #include #define MIN -1234567890 std::vector< std::pair > V[100010]; std::pair x[100010],y[100010]; std::pair W[1010]; int main() { int a,b; scanf("%d%d",&a,&b); for(int i=1;i<=a;i++) { int c,d; scanf("%d%d",&c,&d); V[c].push_back(std::make_pair(d-c,i)); W[i] = std::make_pair(c,d); } std::pair max1 = std::make_pair(MIN,0); std::pair max2 = max1; for(int i=0;i<=100000;i++) { for(int j=0;j100000) { ans = h; min = h+1; goto u; } else if(s2<0); else if(x[s2].second==0); else { if(x[s2].second==i) { if(y[s2].second==0); else { ans = h; min = h+1; goto u; } } else { ans = h; min = h+1; goto u; } } } max = h-1; u:; } printf("%lld",ans); }