prompt
string
response
string
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
import sys import math import itertools import functools import collections import operator import fileinput import copy ORDA = 97 # a def ii(): return int(input()) def mi(): return map(int, input().split()) def li(): return [int(i) for i in input().split()] def lcm(a, b): return abs(a * b) // math.gcd(a, b) def revn...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
import java.awt.Point; import java.io.*; import java.math.BigInteger; import java.util.*; import static java.lang.Math.*; public class ProblemB_14 { final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE")!=null; BufferedReader in; PrintWriter out; StringTokenizer tok = new StringTokenizer(""); void ...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
r=lambda:map(int,raw_input().split()) n,x=r() o=zip(*[sorted(r()) for _ in [0]*n]) a=max(o[0]) b=min(o[1]) if a > b: print -1 elif x < a: print a-x elif x > b:print x-b else: print 0
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.StreamTokenizer; public class Main { private static StreamTokenizer inputReader = new StreamTokenizer( new BufferedReader(new InputStreamReader(System.in))); public static void main(String[] args) { int n = nextInt(); int posit...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class P_14_B_Photographer { public static void main(String[] args) throws IOException { int n; int m; String Line; BufferedReader x = new BufferedReader(new InputStreamReader(Sy...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
#include <bits/stdc++.h> using namespace std; int main() { int n, x; cin >> n >> x; int i, j, a, b; int arr[1005] = {0}; for (i = 0; i < n; i++) { cin >> a >> b; if (a > b) { int t = a; a = b; b = t; } for (j = a; j <= b; j++) { arr[j]++; } } int st = -1, end = ...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
#include <bits/stdc++.h> using namespace std; int main(int argc, char **argv) { int n, x0; int *a = new int[101]; int *b = new int[101]; cin >> n >> x0; int mn = INT_MAX; int mx = INT_MIN; for (int i = 0; i < n; i++) { int o, d; cin >> o >> d; a[i] = min(o, d); b[i] = max(o, d); mx = m...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
import java.util.*; import java.io.*; public class File { public static class FastScanner { BufferedReader br; StringTokenizer st; public FastScanner() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { while (st == null || !st.hasMoreElements()) { try { st ...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
#arr = list(map(int,input().split())) #n,m = map(int,input().split()) #for string inputs: #arr = list(map(int, list(input()))) def solve(): n,x = map(int,input().split()) lis = sorted(list(map(int,input().split()))) for i in range(n-1): a0, b0 = sorted(list(map(int,input().split()))) if a0...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
def intersection(x, y, n): if n == 2: if x[1] < y[0] or y[1] < x[0]: return False else: if x[1] < y[0] or y[1] < x[0] or x[1] == y[0] or x[0] == y[1]: return False return True def solution(): n, x0 = (int(x) for x in input().split()) l, r = 0, 0 maxlen = 0 sportsmans = [] ...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
n, x = map(int, raw_input().split()) s = [1] * 1001 for i in range(n): a, b = map(int, raw_input().split()) if(a > b): t = a a = b b = t for j in range(1001): if(a <= j and j <= b): s[j] &= 1 else: s[j] = 0 ans = 2000 for i in range(1001): ...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
import java.io.*; public class Main { static BufferedReader input; static PrintWriter output; static StreamTokenizer in; public static void main(String[] args) throws IOException { input = new BufferedReader(new InputStreamReader(System.in)); // input = new BufferedReader(new FileReader("input.txt")); out...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
################### #-@ June 25th 2019. ################### ################################################################## # Getting Segment Count and initial Location. count,loc = tuple(map(int,input().split(' '))) # Method to determine if intersection is possible. def empty_intersection(tOne,tTwo): return Tr...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
/* * Hello! You are trying to hack my solution, are you? =) * Don't be afraid of the size, it's just a dump of useful methods like gcd, or n-th Fib number. * And you were successful to hack my solution, please, send me this test. * It can help me improve my skills and i'd be grateful for that. * Good luck, u...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
import java.io.*; import java.math.*; import java.util.*; public class B { public static void main(String[] args) { new B().run(); } class FastScanner { BufferedReader br; StringTokenizer st; boolean eof; String buf; public FastScanner(String fileName) thro...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
n, x0 = raw_input().split(" ") n = int(n) x0 = int(x0) runners = [] for x in range(n): a, b = raw_input().split(" ") a = int(a) b = int(b) a, b = min(a,b), max(a,b) runners.append((a,b)) mindist = 1001 for pos in range(0, 1000+1): if abs(x0 - pos) < mindist: valid = True for x in range(n): ...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
""" Template written to be used by Python Programmers. Use at your own risk!!!! Owned by adi0311(rating - 5 star at CodeChef and Specialist at Codeforces). """ import sys from functools import lru_cache, cmp_to_key from heapq import merge, heapify, heappop, heappush, nlargest, nsmallest, _heapify_max, _heap...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
import java.io.*; import java.util.*; public class YoungPhotographer { public Scanner in; public PrintWriter out; YoungPhotographer() { in = new Scanner(System.in); out = new PrintWriter(System.out); } YoungPhotographer(String i, String o) throws FileNotFoundException { in = new Scanner(new File(i));...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
#include <bits/stdc++.h> using namespace std; int arr[1001]; int main(void) { int i, j, ans, n, x, a, b; memset(arr, 0, sizeof(arr)); ans = 233333; cin >> n >> x; for (i = 0; i < n; i++) { cin >> a >> b; if (a > b) swap(a, b); for (j = a; j <= b; j++) arr[j]++; } for (i = 0; i < 1001; i++) ...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Young_Photographer { public static void main(String[] args) throws IOException { BufferedReader bReader = null; try { bReader = new BufferedReader(new InputStreamReader(System.in, "UTF-8")); String[] s...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
#!/usr/bin/python import sys tmp = raw_input().strip().split(' ') x = int(tmp[1]) left = 0 right = 1000 ret = 0 for line in sys.stdin: tmp = line.strip().split(' ') left = max(left, min(int(tmp[0]), int(tmp[1]))) right = min(right, max(int(tmp[0]), int(tmp[1]))) if left > right: ret = -1 ...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
x, n = list(map(int, input().split())) import sys la = list(map(int, input().split())) la.sort() la[-1] += 1 # print(range(*la)) la = set(range(*la)) for _ in range(x-1): q = list(map(int, input().split())) q.sort() q[-1] += 1 r = range(*q) # print(r) la = la.intersection(r) if not la: ...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
n,x0=map(int,input().split()) l=-1 r=1001 for i in range(n): a,b=map(int,input().split()) l=max(l,min(a,b)) r=min(r,max(a,b)) if(l>r): print("-1") elif(x0>=l and x0<=r): print("0") elif(x0<l): print(l-x0) else: print(x0-r)
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
import java.io.InputStreamReader; import java.io.IOException; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.InputStream; import java.math.BigInteger; import java.text.DecimalFormat; import java.util.ArrayList; import java.util.Ar...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
import java.util.Scanner; import java.util.List; import java.util.ArrayList; import java.util.LinkedList; import java.util.Map; import java.util.HashMap; import java.util.Set; import java.util.HashSet; import java.util.Arrays; import java.util.StringTokenizer; import java.util.TreeSet; import java.util.Collections; imp...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
#include <bits/stdc++.h> using namespace std; int main() { int n, x; scanf("%d%d", &n, &x); int mn = 0, mx = 1e9; for (int i = 0; i < n; i++) { int a, b; scanf("%d%d", &a, &b); if (a > b) swap(a, b); mn = max(mn, a); mx = min(mx, b); } if (mn > mx) printf("-1"); else if (x >= mn &&...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
n,x=map(int,input().split()) a,b=[],[] for i in range(n): p,q=map(int,input().split()) if(p>q): a.append(q) b.append(p) else: a.append(p) b.append(q) result=0 if(max(a)>min(b)): print("-1") exit() if(x>min(b)): result+=(x-min(b)) if(max(a)>x): result+=(max(a)-...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
def young_photographer(): n, x = map(int, input().split()) l, r = None, None for _ in range(n): a, b = map(int, input().split()) a, b = min(a, b), max(a, b) if l is None: l, r = a, b else: l = max(a, l) r = min(b, r) if l > r: ...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n, x0, l = -1, r = 1003, ai, bi; cin >> n >> x0; while (n--) { cin >> ai >> bi; if (ai > bi) swap(ai, bi); l = max(l, ai); r = min(r, bi); } if (l > r) cout << -1...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
I=lambda:map(int, raw_input().split()) n,x=I() q = [] for _ in xrange(n): q.append(sorted(I())) s1,s2 = [max(i[0] for i in q), min(i[1] for i in q)] if s1 > s2: print '-1' elif s1 <= x <= s2: print '0' else: print min(abs(x-s1), abs(x-s2))
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
#include <bits/stdc++.h> using namespace std; int n, x0; struct node { int a, b; } s[110]; int cmp(node l1, node l2) { return l1.a < l2.a; } int main() { int u, v, i; while (cin >> n >> x0) { for (i = 0; i < n; i++) { cin >> u >> v; if (u > v) swap(u, v); s[i].a = u; s[i].b = v; } ...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
import sys from array import array # noqa: F401 def input(): return sys.stdin.buffer.readline().decode('utf-8') n, x0 = map(int, input().split()) imos = [0] * 1010 for ai, bi in (map(int, input().split()) for _ in range(n)): if ai > bi: ai, bi = bi, ai imos[ai] += 1 imos[bi + 1] -= 1 ans =...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
n,x1 = map(int,raw_input().split()) a=[0]*1002 for i in range(n): x,y = map(int,raw_input().split()) for i in range(min(x,y), max(x,y)+1): a[i]+=1 d=[] for i in range(1,1002): if a[i] == n: d.append(i) if len(d) == 0: print -1 else: M=10**12 # print d for i in range(len(d)): if abs(d[i]-x1) < M: M=abs(d...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
n,x0=list(map(int,input().split())) a=[] for i in range(n): a.append(sorted(list(map(int,input().split())))) b=a[0][0] c=a[-1][1] d=-1 for i in range(b,c+1): e=0 for j in a: if j[0]<=i<=j[1]: e+=1 if e==n: if d==-1 or abs(i-x0)<d: d=abs(i-x0) print(d)
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
#include <bits/stdc++.h> using namespace std; int main() { int n, x; cin >> n >> x; int m = -1, M = 10000; vector<pair<int, int> > v(n); for (int i = 0; i < n; i++) { cin >> v[i].first >> v[i].second; int y = max(v[i].first, v[i].second); M = min(M, y); y = min(v[i].first, v[i].second); m ...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
import java.util.Scanner; import java.lang.Math; public class YoungPhotographer { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n, x, a, b, cont, min, max; int[] ar = new int[1001]; n = sc.nextInt(); x = sc.nextInt(); a = b = min = max = 0; cont = Integer.MAX_VALUE; ...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
#include <bits/stdc++.h> using namespace std; int const N = 1234; int a[N], n, m, ans = 10 * N; int main() { scanf("%d%d", &n, &m); for (register int i = 1; i <= n; i++) { int x, y; scanf("%d%d", &x, &y); if (x > y) swap(x, y); for (register int j = x; j <= y; j++) { a[j]++; if (a[j] == ...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
ans = 0 n, x0 = map(int, input().split()) pos = set() for i in range(1001): pos.add(i) for _ in range(n): a, b = map(int, input().split()) if a > b: a, b = b, a pos &= set(range(a, b + 1)) if len(pos) == 0: print(-1) else: ans = 1000 for x in pos: ans = min(ans, abs(x - x0)) print(ans)
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
import java.io.*; import java.util.*; public class CF14B { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(br.readLine()); int n = Integer.parseInt(st.nextToken()); int x = Integer.pa...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
n, x0 = map(int, raw_input().split()) total = 0 amax = 0 bmax = 1000 sa = sb = False for i in xrange(n): a, b = map(int, raw_input().split()) if b < a: a, b = b, a if b < bmax: bmax = b #if b < x0: # sb = True if a > amax: amax = a #if a #sa ...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
import math if __name__ == '__main__': P = lambda: map(int, input().split()) n, x = P() a, b = -1, 1001 for i in range(n): l, r = P() a = max(a, min(l, r)) b = min(b, max(l, r)) print(-1 if b < a else [min(abs(x - a), abs(x - b)), 0][x >= a and x <= b])
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
n, x0 = list(map(int,input().strip().split(' '))) max_s = 0 min_e = 10000000 for i in range(n): s, e = sorted(list(map(int,input().strip().split(' ')))) max_s = max(s,max_s) min_e = min(e,min_e) if x0 >= max_s and x0 <= min_e: print(0) elif min_e < max_s: print(-1) else: print(min(abs(min_e - x0),abs(max_s ...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
import java.io.*; import java.util.*; public class CodeForce { private void solve() throws IOException { int n = nextInt(), x0 = nextInt(); int []a = new int[1001]; int []b = new int[1001]; for(int i = 0; i < n; i++) { int l = nextInt(), r = nextInt(); i...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
import java.util.Scanner; public class YoungPhotographer { /** * @param args */ public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); int x = scanner.nextInt(); int l = 0, r = 1000; int res; for(int i = 0; i < n; ++i) { int a = sca...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class B { public static void main(String[] args) throws IOException{ BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); String[] tmp = in.readLine().split(" "); int n =...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
#include <bits/stdc++.h> using namespace std; struct Seg { int x; int y; int d; } p[100 + 10]; int cmp(Seg a, Seg b) { return a.d < b.d; } int main(void) { int n, x0; cin >> n >> x0; for (int i = 0; i < n; i++) { int a, b; cin >> a >> b; if (a > b) { p[i].x = b; p[i].y = a; } els...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
import java.util.Arrays; import java.util.Scanner; public class B014 { static class end implements Comparable<end> { boolean start; int x; public end(int a, boolean b) { x = a; start = b; } public int compareTo(end o) { int d = x - o.x; if (d == 0) { return start ? -1 : 1; } return d...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n, x, ans = 0, l = 0, r = 1000; cin >> n >> x; for (int i = 0; i < n; i++) { int a, b; cin >> a >> b; if (a > b) swap(a, b); if (a > r or l > b) { ans = -1; ...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
n, x0 = map(int, raw_input().split()) intervals = [map(int, raw_input().split()) for _ in range(n)] ranges = map(lambda (a, b): range(min(a, b), max(a, b) + 1), intervals) intersect = reduce(lambda a, b: set(a).intersection(set(b)), ranges) print "-1" if len(intersect) == 0 else min(map(lambda x: abs(x - x0), intersec...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
import java.util.*; import java.io.*; public class B { private static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { while (st == null || ...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
#include <bits/stdc++.h> using namespace std; using ll = long long; bool stb[70] = {0}; bool st[70] = {0}; void solve() { ll l = 0, r = 10000; ll n, x; cin >> n >> x; for (int i = 0; i < n; i++) { ll a, b; cin >> a >> b; if (a > b) swap(a, b); if (a > l) l = a; if (b < r) r = b; } if (l ...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
import java.util.*; import java.lang.*; import java.io.*; public class Young_PhotoGrapher { public static void main(String[] args)throws java.lang.Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(br.readLine()); int n=Integer.parseIn...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
n,x=input().split() n,x=int(n),int(x) u=10**6 l=0 for i in range(n): a,b=input().split() a,b=int(a),int(b) a,b=sorted([a,b]) u=min(b,u) l=max(a,l) if l>u:print(-1) elif u>=x>=l:print(0) else:print(max(l-x,x-u))
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
#include <bits/stdc++.h> using namespace std; int main() { int i, j, n, x, a1, b1; vector<int> low, high; cin >> n >> x; for (i = 0; i < n; i++) { cin >> a1 >> b1; low.push_back(min(a1, b1)); high.push_back(max(a1, b1)); } sort(low.begin(), low.end(), greater<int>()); sort(high.begin(), high.e...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
import java.util.*; public class S { public static Scanner scan = new Scanner(System.in); public static void main(String[] args) { int n = scan.nextInt(); int x = scan.nextInt(); int max = Integer.MIN_VALUE, min = Integer.MAX_VALUE; for(int i=0; i<n; i++) { int a = scan.nextInt(); int b = scan.n...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
#include <bits/stdc++.h> using namespace std; vector<int> v1, v2; int main() { int n, x, i, j; cin >> n >> x; while (n--) { cin >> i >> j; if (i <= j) { if (v1.empty()) v1.push_back(i); else if (i > v1.back()) v1.push_back(i); if (v2.empty()) v2.push_back(j); ...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
n,x = map(int, raw_input().split()) rs = [map(int, raw_input().split()) for g in xrange(n)] b,e = 0, 1000 for i,j in rs: if i < j: b = max(b, i) e = min(e, j) if i > j: b = max(b, j) e = min(e, i) r = e-b if r < 0: print -1 elif b <= x and x <= e: print 0 else: print ...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
#include <bits/stdc++.h> using namespace std; const long long int maxn = 1e3 + 2; const long long int mod = 1e3 + 2; vector<long long int> d; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long int n, x, ans = INT_MAX; cin >> n >> x; long long int minx = x, maxx = x, a[ma...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
#include <bits/stdc++.h> using namespace std; long long i, n, x0, a, b, p1 = 1000000009, p2; int main() { cin >> n >> x0; for (i = 1; i <= n; i++) { cin >> a >> b; if (b < a) swap(a, b); p1 = min(p1, b); p2 = max(p2, a); } if (p1 < p2) { cout << "-1" << endl; return 0; } if (p1 >= x0...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Scanner; public class R014B { int n; int x0; int[] a; int[] b; public R014B() { Scanner scanner = new Scanner(System.in); n = scanner.nextInt(); x0 = scanner.nextInt(); ...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
# Enter your code here. Read input from STDIN. Print output to STDOUT# =============================================================================================== # importing some useful libraries. from __future__ import division, print_function from fractions import Fraction import sys import os from io import Byt...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
#include <bits/stdc++.h> using namespace std; bool isContains(int n, int m, int v) { return n <= v && v <= m; } int solve() { int n, x0; int a, b; cin >> n >> x0; int mina = -1, maxb = INT_MAX; for (int i = 0; i < n; i++) { cin >> a >> b; if (a > b) swap(a, b); if (isContains(mina, maxb, a) || isC...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
#include <bits/stdc++.h> using namespace std; int main() { int n, x, r = 1000, l = 0; cin >> n >> x; while (n--) { int a, b; cin >> a >> b; r = min(r, max(a, b)); l = max(l, min(a, b)); } if (l > r) cout << "-1"; else if (x <= r && x >= l) cout << "0"; else if (x > r) cout << x...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
#!/usr/bin/python import sys (n, x0) = map(lambda x: int(x), sys.stdin.readline().split()) xmin = -1000 xmax = 2000 for i in range(n): (a, b) = map(lambda x: int(x), sys.stdin.readline().split()) if a > b: a, b = b, a if a > xmin: xmin = a if b < xmax: xmax = b if xmin > xmax: print -1 elif xmin <= x0 and x...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
import sys def differ(x,y,lit): if x > y: x,y = y,x if lit[0] < x: if x > lit[1]: lit[0]=0 lit[1]=0 else: if y>lit[1]: lit[0] = x else: lit[0] = x lit[1] = y else: if y < lit[0]: ...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
n, x = map(int, raw_input().split()) lf = x ri = x cnt = [ 0 for _ in range(1100) ] for i in range(n): a, b = map(int, raw_input().split()) a, b = min(a, b), max(a, b) for j in range(a, b + 1): cnt[j] += 1 dis = 2000 for i in range(1, 1001): if cnt[i] == n: if abs(i - x) < dis: ...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
#include <bits/stdc++.h> using namespace std; int z[1005]; int main() { int n, x; cin >> n >> x; for (int i = 0; i < n; i++) { int a, b; cin >> a >> b; if (a < b) for (int j = a; j <= b; j++) z[j]++; else for (int j = a; j >= b; j--) z[j]++; } int ab = 1e9; for (int i = x; i <= 1...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
#include <bits/stdc++.h> using namespace std; int main() { int i, n, x, a, b, t, p, q; cin >> n >> x; p = -1; q = 10000; for (i = 0; i < n; i++) { cin >> a >> b; if (a > b) { t = a; a = b; b = t; } if (a > p) p = a; if (b < q) q = b; } if (p > q) cout << -1; els...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
function trim(s) { return s.replace(/^\s+|\s+$/gm, ''); } function tokenize(s) { return trim(s).split(/\s+/); } function tokenizeIntegers(s) { var tokens = tokenize(s); for (var i = 0; i < tokens.length; i += 1) { tokens[i] = parseInt(tokens[i]); }; return tokens; } function main() { var integers = tokenize...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
from collections import Counter, defaultdict BS="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" def to_base(s, b): res = "" while s: res+=BS[s%b] s//= b return res[::-1] or "0" alpha = "abcdefghijklmnopqrstuvwxyz" from math import floor, ceil n,x = list(map(int, input().split())) seen = defaultdict...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
import java.io.*; import java.util.*; public class B { static class Race{ int start; int end; public Race(int start, int end) { this.start = start; this.end = end; } } public static void main(String[] args) { FastScanner sc = new FastScanner(); // int yo = sc.nextInt(); // while(yo-->0) { // ...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
n,x=[int(x) for x in input().split()] a,b=[int(x) for x in input().split()] l,r=min(a,b),max(a,b) # print(l,r) f=0 for i in range(n-1): # print(l,r) a,b=[int(x) for x in input().split()] l2,r2=min(a,b),max(a,b) if r2<l or r<l2: f=1 break r=min(r,r2) l=max(l,l2) # print(l,...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
#include <bits/stdc++.h> using namespace std; const long long N = 1e3 + 10; long long n, x, a, b, mx, mxx, mn = INT_MAX; long long arr[N]; vector<long long> v; void solve() { cin >> n >> x; for (long long i = 1; i <= n; i++) { cin >> a >> b; if (a > b) swap(a, b); arr[a] += 1; arr[b + 1] += -1; ...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 1; int n, m; int x, y; int minn = INT_MAX, maxn = INT_MIN; int dis; inline int read() { int X = 0; bool flag = 1; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') flag = 0; ch = getchar(); } while (ch >= '0' && ch <=...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
n,k=map(int,input().split()) a=[] b=[] for i in range(n): a1,b1=sorted(list(map(int,input().split()))) a.append(a1) b.append(b1) x2=max(a) y=min(b) if x2>y: print(-1) elif x2<=k<=y: print(0) else: print(min(abs(k-x2),abs(k-y)))
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
import java.io.*; import java.util.*; import java.math.*; import java.util.regex.*; import java.lang.*; /** * * @author jon */ public class Photo { Photo() throws Exception{ Scanner in = new Scanner(System.in); int N = in.nextInt(); int at = in.nextInt(); int min = 0; int...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
#include <bits/stdc++.h> using namespace std; int min(int a, int b) { return (a < b ? a : b); } int main() { int n, x0, l = 0, r = 1001; cin >> n >> x0; for (int i = 0; i < n; i++) { int x, y; cin >> x >> y; if (x > y) { int t = x; x = y; y = t; } if (x > l) l = x; if (y ...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
n, x0 = map(int, raw_input().split()) ps = [sorted(list(map(int, raw_input().split()))) for i in range(n)] ans = 10000000 for i in range(1001): good = True for j in range(n): if i < ps[j][0] or ps[j][1] < i: good = False break if not good: continue ans = min(ans, abs(i -...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
n, x = map(int, input().split()) _min = 0 _max = 10**4 for i in range(n): a, b = map(int, input().split()) _min = max(_min, min(a, b)) _max = min(_max, max(a, b)) if _min > _max: print(-1) elif _max > x > _min: print(0) else: print(min(abs(x-_min), abs(x-_max)))
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
#include <bits/stdc++.h> using namespace std; long long a[500010]; map<long long, long long> m; vector<long long> v; string s, q; int main() { long long t = 1, n, i, j, k, l, r, mn = 0, mx = 0, x, y; while (t--) { scanf("%lld%lld", &n, &k); l = 0, r = INT_MAX; long long ans = 0; for (int i = 0; i < ...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
import java.util.Scanner; public class B { public static void main(String[] args) { new B(); } B() { Scanner in=new Scanner(System.in); int n=in.nextInt(); int x0=in.nextInt(); int[][] R=new int[n][2]; for (int i=0; i<n; ++i) { int x=in.nextInt(); int y=in.nextInt(); if (x>y) { i...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
#include <bits/stdc++.h> using namespace std; long long int a[5]; int main() { long long int n, m, i, j, k, l, x, y, z, t; cin >> n >> k; long long int cnt = 0; long long int p = -1, q = 1e18; for (i = 0; i < n; i++) { cin >> x >> y; if (x > y) swap(x, y); p = max(p, x); q = min(q, y); } i...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
from collections import deque, defaultdict, Counter from itertools import product, groupby, permutations, combinations from math import gcd, floor, inf, log2, sqrt, log10 from bisect import bisect_right, bisect_left from statistics import mode from string import ascii_uppercase cases, x = map(int, (input().split())) ...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
#include <bits/stdc++.h> using namespace std; int main() { int n, x; cin >> n >> x; vector<pair<int, int> > players; for (int i = 0; i < n; i++) { int a, b; cin >> a >> b; if (a > b) swap(a, b); players.push_back(make_pair(a, b)); } int ans = INT_MAX; for (int pos = 0; pos <= 1000; pos++) ...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
import java.io.*; import java.util.*; import static java.lang.Math.*; import java.math.*; public class Main { StreamTokenizer in; PrintWriter out; public static void main(String[] args) throws IOException { new Main().run(); } void run() throws IOException { //in = new StreamTokeniz...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
import java.util.Arrays; import java.io.InputStream; import java.io.InputStreamReader; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.Comparator; import java.io.IOException; import java.util.StringTokenizer; public class B { public static void main(String[]...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
#include <bits/stdc++.h> using namespace std; const int INF = 1 << 29; const double PI = acos(-1); const double EPS = 1e-8; int main() { int n, x0; cin >> n >> x0; int a = -INF; int b = INF; for (int i = 0; i < (int)n; ++i) { int x, y; cin >> x >> y; a = max(a, min(x, y)); b = min(b, max(x, y)...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
#include <bits/stdc++.h> using namespace std; const int INFI = 2000000000; const int goX[4] = {-1, 0, 1, 0}; const int goY[4] = {0, 1, 0, -1}; const string PROBLEM_NAME = "B"; const string INPUT_FILE = PROBLEM_NAME + ".in"; const string OUTPUT_FILE = PROBLEM_NAME + ".out"; vector<pair<int, int>> vp; int n, x0; void rea...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
import java.util.Scanner; import java.lang.*; import java.io.*; public class pb1 { public static void main (String[] args) { Scanner in = new Scanner(System.in); int n, x; n = in.nextInt(); x = in.nextInt(); int temp = 0; int min = Integer.MAX_VALUE, max = 0; for(int i=1; i<=n; i++) { int a,b; ...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.io.BufferedWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.Writer; import java.io.OutputStreamWriter; import java.io.Input...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
import java.util.*; public class Young_Photographer { public static void main(String[]args){ int n,x; Scanner input = new Scanner(System.in); n = input.nextInt(); x = input.nextInt(); int move = 0; int[] first = new int[n]; int[] second = new int[n]; boolean con = true; for(int i ...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
#include <bits/stdc++.h> using namespace std; int n, pos, maxx = INT_MIN, x, y, minn = INT_MAX; int minnn(int a, int b) { if (a <= b) return a; else return b; } int maxxx(int x, int y) { if (x >= y) return x; else return y; } int main() { scanf("%d %d", &n, &pos); for (int i = 1; i <= n; i++...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
n,x = [int(i) for i in raw_input().split()] c = [] for i in xrange(0,2000): c.append(0) for i in xrange(0,n): a,b = [int(j) for j in raw_input().split()] if a <= b: for j in xrange(a,b+1): c[j]+=1 else: for j in xrange(b,a+1): c[j]+=1 m = 1001 for i in xrange...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
# Author : nitish420 -------------------------------------------------------------------- import os import sys from io import BytesIO, IOBase # mod=10**9+7 # sys.setrecursionlimit(10**6) # mxm=sys.maxsize # from functools import lru_cache def main(): n,z=map(int,input().split()) l=[] for _ in range(n): ...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
#include <bits/stdc++.h> using namespace std; int const OO = (1 << 28); int main() { int mn = OO, mx = -1; int N, X; cin >> N >> X; vector<pair<int, int> > V(N); for (int i = 0; i < N; ++i) { cin >> V[i].first >> V[i].second; if (V[i].first > V[i].second) swap(V[i].first, V[i].second); mn = min(V[...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
f_input = lambda: map(int, raw_input().split()) n, x0 = f_input() segs = zip(*[sorted(f_input()) for _ in [0]*n]) m, M = max(segs[0]), min(segs[1]) if m > M: print "-1" elif x0 < m: print m - x0 elif x0 > M: print x0 - M else: print "0"
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
#include <bits/stdc++.h> using namespace std; long long lcm(long long a, long long b); long long gcd(long long a, long long b); long long cross_prod(long long ax, long long ay, long long bx, long long by, long long cx, long long cy); long long sum_digit(long long A); long long get_mask(long long x)...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
import java.util.*; public class Test { public static void main(String[] args){ Scanner scan = new Scanner(System.in); int n = scan.nextInt(); int x0 = scan.nextInt(); int[][] a = new int[n][2]; for(int i = 0; i < n; i++){ a[i][0] = scan.nextInt(); ...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
# link: https://codeforces.com/problemset/problem/14/B if __name__ == "__main__": n,x = map(int,input().split()) a = [0 for i in range(1006)] temp = 0 answer = float('inf') for i in range(n): info = list(map(int, input().split())) info.sort() a[info[0]] += 1 a[info[1]...
Problem: Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, traini...
// "static void main" must be defined in a public class. import java.util.*; public class Main { public static void main(String[] args) { try{Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int x=sc.nextInt(); int count=0; int c=0; int d=1005; while(n-->...