message stringlengths 2 44.5k | message_type stringclasses 2
values | message_id int64 0 1 | conversation_id int64 276 109k | cluster float64 23 23 | __index_level_0__ int64 552 217k |
|---|---|---|---|---|---|
Provide tags and a correct Python 3 solution for this coding contest problem.
Vasily the bear has a favorite rectangle, it has one vertex at point (0, 0), and the opposite vertex at point (x, y). Of course, the sides of Vasya's favorite rectangle are parallel to the coordinate axes.
Vasya also loves triangles, if the triangles have one vertex at point B = (0, 0). That's why today he asks you to find two points A = (x1, y1) and C = (x2, y2), such that the following conditions hold:
* the coordinates of points: x1, x2, y1, y2 are integers. Besides, the following inequation holds: x1 < x2;
* the triangle formed by point A, B and C is rectangular and isosceles (<image> is right);
* all points of the favorite rectangle are located inside or on the border of triangle ABC;
* the area of triangle ABC is as small as possible.
Help the bear, find the required points. It is not so hard to proof that these points are unique.
Input
The first line contains two integers x, y ( - 109 β€ x, y β€ 109, x β 0, y β 0).
Output
Print in the single line four integers x1, y1, x2, y2 β the coordinates of the required points.
Examples
Input
10 5
Output
0 15 15 0
Input
-10 5
Output
-15 0 0 15
Note
<image>
Figure to the first sample | instruction | 0 | 55,917 | 23 | 111,834 |
Tags: implementation, math
Correct Solution:
```
import sys, os.path
if(os.path.exists('in_py.txt')):
sys.stdin = open("in_py.txt","r")
sys.stdout = open("out_py.txt","w")
def get_ints(): return map(int, sys.stdin.readline().strip().split())
n=1
x,y=get_ints()
x2=y2=x3=y3=0
while(n>0):
n=n-1
if(x>0 and y>0):
x2=0
y2=abs(x)+abs(y)
x3=abs(x)+abs(y)
y3=0
elif(x>0 and y<0):
x2=0
y2=-(abs(x)+abs(y))
y3=0
x3=(abs(x)+abs(y))
elif(x<0 and y>0):
x2=-(abs(x)+abs(y))
y2=0
x3=0
y3=abs(x)+abs(y)
else:
x3=0
y3=-(abs(x)+abs(y))
x2=-(abs(x)+abs(y))
y2=0
print(x2,y2,x3,y3)
``` | output | 1 | 55,917 | 23 | 111,835 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vasily the bear has a favorite rectangle, it has one vertex at point (0, 0), and the opposite vertex at point (x, y). Of course, the sides of Vasya's favorite rectangle are parallel to the coordinate axes.
Vasya also loves triangles, if the triangles have one vertex at point B = (0, 0). That's why today he asks you to find two points A = (x1, y1) and C = (x2, y2), such that the following conditions hold:
* the coordinates of points: x1, x2, y1, y2 are integers. Besides, the following inequation holds: x1 < x2;
* the triangle formed by point A, B and C is rectangular and isosceles (<image> is right);
* all points of the favorite rectangle are located inside or on the border of triangle ABC;
* the area of triangle ABC is as small as possible.
Help the bear, find the required points. It is not so hard to proof that these points are unique.
Input
The first line contains two integers x, y ( - 109 β€ x, y β€ 109, x β 0, y β 0).
Output
Print in the single line four integers x1, y1, x2, y2 β the coordinates of the required points.
Examples
Input
10 5
Output
0 15 15 0
Input
-10 5
Output
-15 0 0 15
Note
<image>
Figure to the first sample | instruction | 0 | 55,918 | 23 | 111,836 |
Tags: implementation, math
Correct Solution:
```
x,y=[int(x) for x in input().split(' ')]
if(x>0 and y>0):
print(0,x+y,x+y,0)
elif(x<0 and y>0):
print(x-y,0,0,y-x)
elif(x>0 and y<0):
print(0,y-x,x-y,0)
else:
print(x+y,0,0,x+y)
``` | output | 1 | 55,918 | 23 | 111,837 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vasily the bear has a favorite rectangle, it has one vertex at point (0, 0), and the opposite vertex at point (x, y). Of course, the sides of Vasya's favorite rectangle are parallel to the coordinate axes.
Vasya also loves triangles, if the triangles have one vertex at point B = (0, 0). That's why today he asks you to find two points A = (x1, y1) and C = (x2, y2), such that the following conditions hold:
* the coordinates of points: x1, x2, y1, y2 are integers. Besides, the following inequation holds: x1 < x2;
* the triangle formed by point A, B and C is rectangular and isosceles (<image> is right);
* all points of the favorite rectangle are located inside or on the border of triangle ABC;
* the area of triangle ABC is as small as possible.
Help the bear, find the required points. It is not so hard to proof that these points are unique.
Input
The first line contains two integers x, y ( - 109 β€ x, y β€ 109, x β 0, y β 0).
Output
Print in the single line four integers x1, y1, x2, y2 β the coordinates of the required points.
Examples
Input
10 5
Output
0 15 15 0
Input
-10 5
Output
-15 0 0 15
Note
<image>
Figure to the first sample | instruction | 0 | 55,919 | 23 | 111,838 |
Tags: implementation, math
Correct Solution:
```
x,y = [int(i) for i in input().split()]
b = abs(y)
if(x>0 and y>0):
print(0,x+b,x+b,0)
elif(x>0 and y<0):
print(0,-x-b,x+b,0)
elif(x<0 and y>0):
print(x-b,0,0,abs(x)+b)
elif(x<0 and y<0):
print(y+x,0,0,y+x)
``` | output | 1 | 55,919 | 23 | 111,839 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vasily the bear has a favorite rectangle, it has one vertex at point (0, 0), and the opposite vertex at point (x, y). Of course, the sides of Vasya's favorite rectangle are parallel to the coordinate axes.
Vasya also loves triangles, if the triangles have one vertex at point B = (0, 0). That's why today he asks you to find two points A = (x1, y1) and C = (x2, y2), such that the following conditions hold:
* the coordinates of points: x1, x2, y1, y2 are integers. Besides, the following inequation holds: x1 < x2;
* the triangle formed by point A, B and C is rectangular and isosceles (<image> is right);
* all points of the favorite rectangle are located inside or on the border of triangle ABC;
* the area of triangle ABC is as small as possible.
Help the bear, find the required points. It is not so hard to proof that these points are unique.
Input
The first line contains two integers x, y ( - 109 β€ x, y β€ 109, x β 0, y β 0).
Output
Print in the single line four integers x1, y1, x2, y2 β the coordinates of the required points.
Examples
Input
10 5
Output
0 15 15 0
Input
-10 5
Output
-15 0 0 15
Note
<image>
Figure to the first sample | instruction | 0 | 55,920 | 23 | 111,840 |
Tags: implementation, math
Correct Solution:
```
arr = input().split()
a = int(arr[0])
b = int(arr[1])
l = abs(a) + abs(b)
if a >= 0:
x = l
else:
x = -1*l
if b >= 0:
y = l
else:
y = -1*l
if x > 0:
print('0 ' + str(y) + ' ' + str(x) + ' 0')
else:
print(str(x) + ' 0 0 ' + str(y) )
``` | output | 1 | 55,920 | 23 | 111,841 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vasily the bear has a favorite rectangle, it has one vertex at point (0, 0), and the opposite vertex at point (x, y). Of course, the sides of Vasya's favorite rectangle are parallel to the coordinate axes.
Vasya also loves triangles, if the triangles have one vertex at point B = (0, 0). That's why today he asks you to find two points A = (x1, y1) and C = (x2, y2), such that the following conditions hold:
* the coordinates of points: x1, x2, y1, y2 are integers. Besides, the following inequation holds: x1 < x2;
* the triangle formed by point A, B and C is rectangular and isosceles (<image> is right);
* all points of the favorite rectangle are located inside or on the border of triangle ABC;
* the area of triangle ABC is as small as possible.
Help the bear, find the required points. It is not so hard to proof that these points are unique.
Input
The first line contains two integers x, y ( - 109 β€ x, y β€ 109, x β 0, y β 0).
Output
Print in the single line four integers x1, y1, x2, y2 β the coordinates of the required points.
Examples
Input
10 5
Output
0 15 15 0
Input
-10 5
Output
-15 0 0 15
Note
<image>
Figure to the first sample | instruction | 0 | 55,921 | 23 | 111,842 |
Tags: implementation, math
Correct Solution:
```
def sgn(n):
if n>0: return 1
return -1
x,y=map(int,input().split())
v=abs(x)+abs(y)
l=[[v*sgn(x),0],[0,v*sgn(y)]]
if l[0][0]>l[1][0]:
l[0],l[1]=l[1],l[0]
for x in l:
print(*x,end=' ')
``` | output | 1 | 55,921 | 23 | 111,843 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vasily the bear has a favorite rectangle, it has one vertex at point (0, 0), and the opposite vertex at point (x, y). Of course, the sides of Vasya's favorite rectangle are parallel to the coordinate axes.
Vasya also loves triangles, if the triangles have one vertex at point B = (0, 0). That's why today he asks you to find two points A = (x1, y1) and C = (x2, y2), such that the following conditions hold:
* the coordinates of points: x1, x2, y1, y2 are integers. Besides, the following inequation holds: x1 < x2;
* the triangle formed by point A, B and C is rectangular and isosceles (<image> is right);
* all points of the favorite rectangle are located inside or on the border of triangle ABC;
* the area of triangle ABC is as small as possible.
Help the bear, find the required points. It is not so hard to proof that these points are unique.
Input
The first line contains two integers x, y ( - 109 β€ x, y β€ 109, x β 0, y β 0).
Output
Print in the single line four integers x1, y1, x2, y2 β the coordinates of the required points.
Examples
Input
10 5
Output
0 15 15 0
Input
-10 5
Output
-15 0 0 15
Note
<image>
Figure to the first sample | instruction | 0 | 55,922 | 23 | 111,844 |
Tags: implementation, math
Correct Solution:
```
x, y = [int(i) for i in input().split()]
sign = lambda n: n // abs(n)
x1 = (abs(x) + abs(y)) * sign(x)
y1 = (abs(x) + abs(y)) * sign(y)
if x1 < 0:
print(x1, 0, 0, y1)
else:
print(0, y1, x1, 0)
``` | output | 1 | 55,922 | 23 | 111,845 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vasily the bear has a favorite rectangle, it has one vertex at point (0, 0), and the opposite vertex at point (x, y). Of course, the sides of Vasya's favorite rectangle are parallel to the coordinate axes.
Vasya also loves triangles, if the triangles have one vertex at point B = (0, 0). That's why today he asks you to find two points A = (x1, y1) and C = (x2, y2), such that the following conditions hold:
* the coordinates of points: x1, x2, y1, y2 are integers. Besides, the following inequation holds: x1 < x2;
* the triangle formed by point A, B and C is rectangular and isosceles (<image> is right);
* all points of the favorite rectangle are located inside or on the border of triangle ABC;
* the area of triangle ABC is as small as possible.
Help the bear, find the required points. It is not so hard to proof that these points are unique.
Input
The first line contains two integers x, y ( - 109 β€ x, y β€ 109, x β 0, y β 0).
Output
Print in the single line four integers x1, y1, x2, y2 β the coordinates of the required points.
Examples
Input
10 5
Output
0 15 15 0
Input
-10 5
Output
-15 0 0 15
Note
<image>
Figure to the first sample | instruction | 0 | 55,923 | 23 | 111,846 |
Tags: implementation, math
Correct Solution:
```
p=input().split()
x=int(p[0])
y=int(p[1])
if x>0 and y>0:
a=0
b=x+y
c=x+y
d=0
elif x<0 and y>0:
a=x-y
b=0
c=0
d=y-x
elif x<0 and y<0:
a=x+y
b=0
c=0
d=x+y
elif x>0 and y<0:
a=0
b=y-x
c=x-y
d=0
print(a,b,c,d)
``` | output | 1 | 55,923 | 23 | 111,847 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vasily the bear has a favorite rectangle, it has one vertex at point (0, 0), and the opposite vertex at point (x, y). Of course, the sides of Vasya's favorite rectangle are parallel to the coordinate axes.
Vasya also loves triangles, if the triangles have one vertex at point B = (0, 0). That's why today he asks you to find two points A = (x1, y1) and C = (x2, y2), such that the following conditions hold:
* the coordinates of points: x1, x2, y1, y2 are integers. Besides, the following inequation holds: x1 < x2;
* the triangle formed by point A, B and C is rectangular and isosceles (<image> is right);
* all points of the favorite rectangle are located inside or on the border of triangle ABC;
* the area of triangle ABC is as small as possible.
Help the bear, find the required points. It is not so hard to proof that these points are unique.
Input
The first line contains two integers x, y ( - 109 β€ x, y β€ 109, x β 0, y β 0).
Output
Print in the single line four integers x1, y1, x2, y2 β the coordinates of the required points.
Examples
Input
10 5
Output
0 15 15 0
Input
-10 5
Output
-15 0 0 15
Note
<image>
Figure to the first sample
Submitted Solution:
```
x,y=map(int,input().split())
if x>0 and y>0:
c=x+y
x1=0
y1=c
x2=c
y2=0
elif x<0 and y>0:
c=y-x
x1=-c
y1=0
x2=0
y2=c
elif x<0 and y<0:
c=-y-x
x1=-c
y1=0
x2=0
y2=-c
else:
c=x-y
x1=0
y1=-c
x2=c
y2=0
print(f"{x1} {y1} {x2} {y2}")
``` | instruction | 0 | 55,924 | 23 | 111,848 |
Yes | output | 1 | 55,924 | 23 | 111,849 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vasily the bear has a favorite rectangle, it has one vertex at point (0, 0), and the opposite vertex at point (x, y). Of course, the sides of Vasya's favorite rectangle are parallel to the coordinate axes.
Vasya also loves triangles, if the triangles have one vertex at point B = (0, 0). That's why today he asks you to find two points A = (x1, y1) and C = (x2, y2), such that the following conditions hold:
* the coordinates of points: x1, x2, y1, y2 are integers. Besides, the following inequation holds: x1 < x2;
* the triangle formed by point A, B and C is rectangular and isosceles (<image> is right);
* all points of the favorite rectangle are located inside or on the border of triangle ABC;
* the area of triangle ABC is as small as possible.
Help the bear, find the required points. It is not so hard to proof that these points are unique.
Input
The first line contains two integers x, y ( - 109 β€ x, y β€ 109, x β 0, y β 0).
Output
Print in the single line four integers x1, y1, x2, y2 β the coordinates of the required points.
Examples
Input
10 5
Output
0 15 15 0
Input
-10 5
Output
-15 0 0 15
Note
<image>
Figure to the first sample
Submitted Solution:
```
if __name__ == '__main__':
x, y = map(int, input().split())
if x < 0:
if y > 0:
print(' '.join(map(str, [x - y, 0, 0, y - x])))
if y < 0:
print(' '.join(map(str, [x + y, 0, 0, y + x])))
if x > 0:
if y > 0:
print(' '.join(map(str, [0, y + x, x + y, 0])))
if y < 0:
print(' '.join(map(str, [0, y - x, x - y, 0])))
``` | instruction | 0 | 55,925 | 23 | 111,850 |
Yes | output | 1 | 55,925 | 23 | 111,851 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vasily the bear has a favorite rectangle, it has one vertex at point (0, 0), and the opposite vertex at point (x, y). Of course, the sides of Vasya's favorite rectangle are parallel to the coordinate axes.
Vasya also loves triangles, if the triangles have one vertex at point B = (0, 0). That's why today he asks you to find two points A = (x1, y1) and C = (x2, y2), such that the following conditions hold:
* the coordinates of points: x1, x2, y1, y2 are integers. Besides, the following inequation holds: x1 < x2;
* the triangle formed by point A, B and C is rectangular and isosceles (<image> is right);
* all points of the favorite rectangle are located inside or on the border of triangle ABC;
* the area of triangle ABC is as small as possible.
Help the bear, find the required points. It is not so hard to proof that these points are unique.
Input
The first line contains two integers x, y ( - 109 β€ x, y β€ 109, x β 0, y β 0).
Output
Print in the single line four integers x1, y1, x2, y2 β the coordinates of the required points.
Examples
Input
10 5
Output
0 15 15 0
Input
-10 5
Output
-15 0 0 15
Note
<image>
Figure to the first sample
Submitted Solution:
```
x, y = map(int, input().split())
if x > 0 and y > 0: print(0, x+y, x+y, 0)
if x < 0 and y > 0: print(-1*(abs(x)+abs(y)),0, 0, abs(x)+abs(y))
if x < 0 and y < 0: print(-1*(abs(x)+abs(y)),0, 0, -1 * (abs(x)+abs(y)))
if x > 0 and y < 0: print(0, -1*(abs(x)+abs(y)), abs(x)+abs(y), 0)
``` | instruction | 0 | 55,926 | 23 | 111,852 |
Yes | output | 1 | 55,926 | 23 | 111,853 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vasily the bear has a favorite rectangle, it has one vertex at point (0, 0), and the opposite vertex at point (x, y). Of course, the sides of Vasya's favorite rectangle are parallel to the coordinate axes.
Vasya also loves triangles, if the triangles have one vertex at point B = (0, 0). That's why today he asks you to find two points A = (x1, y1) and C = (x2, y2), such that the following conditions hold:
* the coordinates of points: x1, x2, y1, y2 are integers. Besides, the following inequation holds: x1 < x2;
* the triangle formed by point A, B and C is rectangular and isosceles (<image> is right);
* all points of the favorite rectangle are located inside or on the border of triangle ABC;
* the area of triangle ABC is as small as possible.
Help the bear, find the required points. It is not so hard to proof that these points are unique.
Input
The first line contains two integers x, y ( - 109 β€ x, y β€ 109, x β 0, y β 0).
Output
Print in the single line four integers x1, y1, x2, y2 β the coordinates of the required points.
Examples
Input
10 5
Output
0 15 15 0
Input
-10 5
Output
-15 0 0 15
Note
<image>
Figure to the first sample
Submitted Solution:
```
x, y = map(int, input().split())
a = abs(x) + abs(y)
if x > 0:
print(0, a * y // abs(y), a, 0)
else:
print(-a, 0, 0, a * y // abs(y))
``` | instruction | 0 | 55,927 | 23 | 111,854 |
Yes | output | 1 | 55,927 | 23 | 111,855 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vasily the bear has a favorite rectangle, it has one vertex at point (0, 0), and the opposite vertex at point (x, y). Of course, the sides of Vasya's favorite rectangle are parallel to the coordinate axes.
Vasya also loves triangles, if the triangles have one vertex at point B = (0, 0). That's why today he asks you to find two points A = (x1, y1) and C = (x2, y2), such that the following conditions hold:
* the coordinates of points: x1, x2, y1, y2 are integers. Besides, the following inequation holds: x1 < x2;
* the triangle formed by point A, B and C is rectangular and isosceles (<image> is right);
* all points of the favorite rectangle are located inside or on the border of triangle ABC;
* the area of triangle ABC is as small as possible.
Help the bear, find the required points. It is not so hard to proof that these points are unique.
Input
The first line contains two integers x, y ( - 109 β€ x, y β€ 109, x β 0, y β 0).
Output
Print in the single line four integers x1, y1, x2, y2 β the coordinates of the required points.
Examples
Input
10 5
Output
0 15 15 0
Input
-10 5
Output
-15 0 0 15
Note
<image>
Figure to the first sample
Submitted Solution:
```
x,y = [int(i) for i in input().split()]
b = abs(y)
if(x>0 and y>0):
print(0,x+b,x+b,0)
elif(x>0 and y<0):
print(0,-x-b,x+b,0)
elif(x<0 and y>0):
print(x-b,0,0,abs(x)+b)
elif(x<0 and y<0):
print(y,0,0,y+x)
``` | instruction | 0 | 55,928 | 23 | 111,856 |
No | output | 1 | 55,928 | 23 | 111,857 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vasily the bear has a favorite rectangle, it has one vertex at point (0, 0), and the opposite vertex at point (x, y). Of course, the sides of Vasya's favorite rectangle are parallel to the coordinate axes.
Vasya also loves triangles, if the triangles have one vertex at point B = (0, 0). That's why today he asks you to find two points A = (x1, y1) and C = (x2, y2), such that the following conditions hold:
* the coordinates of points: x1, x2, y1, y2 are integers. Besides, the following inequation holds: x1 < x2;
* the triangle formed by point A, B and C is rectangular and isosceles (<image> is right);
* all points of the favorite rectangle are located inside or on the border of triangle ABC;
* the area of triangle ABC is as small as possible.
Help the bear, find the required points. It is not so hard to proof that these points are unique.
Input
The first line contains two integers x, y ( - 109 β€ x, y β€ 109, x β 0, y β 0).
Output
Print in the single line four integers x1, y1, x2, y2 β the coordinates of the required points.
Examples
Input
10 5
Output
0 15 15 0
Input
-10 5
Output
-15 0 0 15
Note
<image>
Figure to the first sample
Submitted Solution:
```
x, y = map(int, input().split())
x1, x2, y1, y2 = 0, 0, 0, 0
if x > 0:
x1 = 0
y1 = 3 * y
if y < 0:
y1 = -y1
x2 = int(1.5 * x)
y2 = 0
elif x < 0 and y > 0:
x1 = int(1.5 * x)
y1 = 0
x2 = 0
y2 = 3 * y
if y < 0:
y2 = -y2
print("{} {} {} {}".format(x1, y1, x2, y2))
``` | instruction | 0 | 55,929 | 23 | 111,858 |
No | output | 1 | 55,929 | 23 | 111,859 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vasily the bear has a favorite rectangle, it has one vertex at point (0, 0), and the opposite vertex at point (x, y). Of course, the sides of Vasya's favorite rectangle are parallel to the coordinate axes.
Vasya also loves triangles, if the triangles have one vertex at point B = (0, 0). That's why today he asks you to find two points A = (x1, y1) and C = (x2, y2), such that the following conditions hold:
* the coordinates of points: x1, x2, y1, y2 are integers. Besides, the following inequation holds: x1 < x2;
* the triangle formed by point A, B and C is rectangular and isosceles (<image> is right);
* all points of the favorite rectangle are located inside or on the border of triangle ABC;
* the area of triangle ABC is as small as possible.
Help the bear, find the required points. It is not so hard to proof that these points are unique.
Input
The first line contains two integers x, y ( - 109 β€ x, y β€ 109, x β 0, y β 0).
Output
Print in the single line four integers x1, y1, x2, y2 β the coordinates of the required points.
Examples
Input
10 5
Output
0 15 15 0
Input
-10 5
Output
-15 0 0 15
Note
<image>
Figure to the first sample
Submitted Solution:
```
a,b = map(int,input().split())
val = abs(a) +abs(b)
p =val*a//a
q=0
x=0
y= val*b//b
if(p>0 ):
print(q,p,y,x)
else:
print(p,q,x,y)
``` | instruction | 0 | 55,930 | 23 | 111,860 |
No | output | 1 | 55,930 | 23 | 111,861 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vasily the bear has a favorite rectangle, it has one vertex at point (0, 0), and the opposite vertex at point (x, y). Of course, the sides of Vasya's favorite rectangle are parallel to the coordinate axes.
Vasya also loves triangles, if the triangles have one vertex at point B = (0, 0). That's why today he asks you to find two points A = (x1, y1) and C = (x2, y2), such that the following conditions hold:
* the coordinates of points: x1, x2, y1, y2 are integers. Besides, the following inequation holds: x1 < x2;
* the triangle formed by point A, B and C is rectangular and isosceles (<image> is right);
* all points of the favorite rectangle are located inside or on the border of triangle ABC;
* the area of triangle ABC is as small as possible.
Help the bear, find the required points. It is not so hard to proof that these points are unique.
Input
The first line contains two integers x, y ( - 109 β€ x, y β€ 109, x β 0, y β 0).
Output
Print in the single line four integers x1, y1, x2, y2 β the coordinates of the required points.
Examples
Input
10 5
Output
0 15 15 0
Input
-10 5
Output
-15 0 0 15
Note
<image>
Figure to the first sample
Submitted Solution:
```
a, b = map(int, input().split())
c = abs(a) + abs(b)
u, v = (2 * (a > 0) - 1) * c, (2 * (b > 0) - 1) * c
if a > 0:
if b > 0: print(0, c, c, 0)
else: print(0, c, -c, 0)
else:
if b > 0: print(-c, 0, 0, c)
else: print(-c, 0, 0, -c)
``` | instruction | 0 | 55,931 | 23 | 111,862 |
No | output | 1 | 55,931 | 23 | 111,863 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of them is the following.
Iahub wants to draw n distinct points and m segments on the OX axis. He can draw each point with either red or blue. The drawing is good if and only if the following requirement is met: for each segment [li, ri] consider all the red points belong to it (ri points), and all the blue points belong to it (bi points); each segment i should satisfy the inequality |ri - bi| β€ 1.
Iahub thinks that point x belongs to segment [l, r], if inequality l β€ x β€ r holds.
Iahub gives to you all coordinates of points and segments. Please, help him to find any good drawing.
Input
The first line of input contains two integers: n (1 β€ n β€ 100) and m (1 β€ m β€ 100). The next line contains n space-separated integers x1, x2, ..., xn (0 β€ xi β€ 100) β the coordinates of the points. The following m lines contain the descriptions of the m segments. Each line contains two integers li and ri (0 β€ li β€ ri β€ 100) β the borders of the i-th segment.
It's guaranteed that all the points are distinct.
Output
If there is no good drawing for a given test, output a single integer -1. Otherwise output n integers, each integer must be 0 or 1. The i-th number denotes the color of the i-th point (0 is red, and 1 is blue).
If there are multiple good drawings you can output any of them.
Examples
Input
3 3
3 7 14
1 5
6 10
11 15
Output
0 0 0
Input
3 4
1 2 3
1 2
2 3
5 6
2 2
Output
1 0 1 | instruction | 0 | 55,964 | 23 | 111,928 |
Tags: constructive algorithms, sortings
Correct Solution:
```
n, m = map(int, input().split())
a = [int(i) for i in input().split()]
b = sorted([[a[i], i] for i in range(n)])
for i in range(m):
l, r = map(int, input().split())
for i in range(n):
a[b[i][1]] = str(i%2)
print(' '.join(a))
``` | output | 1 | 55,964 | 23 | 111,929 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of them is the following.
Iahub wants to draw n distinct points and m segments on the OX axis. He can draw each point with either red or blue. The drawing is good if and only if the following requirement is met: for each segment [li, ri] consider all the red points belong to it (ri points), and all the blue points belong to it (bi points); each segment i should satisfy the inequality |ri - bi| β€ 1.
Iahub thinks that point x belongs to segment [l, r], if inequality l β€ x β€ r holds.
Iahub gives to you all coordinates of points and segments. Please, help him to find any good drawing.
Input
The first line of input contains two integers: n (1 β€ n β€ 100) and m (1 β€ m β€ 100). The next line contains n space-separated integers x1, x2, ..., xn (0 β€ xi β€ 100) β the coordinates of the points. The following m lines contain the descriptions of the m segments. Each line contains two integers li and ri (0 β€ li β€ ri β€ 100) β the borders of the i-th segment.
It's guaranteed that all the points are distinct.
Output
If there is no good drawing for a given test, output a single integer -1. Otherwise output n integers, each integer must be 0 or 1. The i-th number denotes the color of the i-th point (0 is red, and 1 is blue).
If there are multiple good drawings you can output any of them.
Examples
Input
3 3
3 7 14
1 5
6 10
11 15
Output
0 0 0
Input
3 4
1 2 3
1 2
2 3
5 6
2 2
Output
1 0 1 | instruction | 0 | 55,965 | 23 | 111,930 |
Tags: constructive algorithms, sortings
Correct Solution:
```
input()
P=list(map(int,input().split()))
for a,b in sorted([[P.index(p),i%2]for i,p in enumerate(sorted(P))]):print(b)
``` | output | 1 | 55,965 | 23 | 111,931 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of them is the following.
Iahub wants to draw n distinct points and m segments on the OX axis. He can draw each point with either red or blue. The drawing is good if and only if the following requirement is met: for each segment [li, ri] consider all the red points belong to it (ri points), and all the blue points belong to it (bi points); each segment i should satisfy the inequality |ri - bi| β€ 1.
Iahub thinks that point x belongs to segment [l, r], if inequality l β€ x β€ r holds.
Iahub gives to you all coordinates of points and segments. Please, help him to find any good drawing.
Input
The first line of input contains two integers: n (1 β€ n β€ 100) and m (1 β€ m β€ 100). The next line contains n space-separated integers x1, x2, ..., xn (0 β€ xi β€ 100) β the coordinates of the points. The following m lines contain the descriptions of the m segments. Each line contains two integers li and ri (0 β€ li β€ ri β€ 100) β the borders of the i-th segment.
It's guaranteed that all the points are distinct.
Output
If there is no good drawing for a given test, output a single integer -1. Otherwise output n integers, each integer must be 0 or 1. The i-th number denotes the color of the i-th point (0 is red, and 1 is blue).
If there are multiple good drawings you can output any of them.
Examples
Input
3 3
3 7 14
1 5
6 10
11 15
Output
0 0 0
Input
3 4
1 2 3
1 2
2 3
5 6
2 2
Output
1 0 1 | instruction | 0 | 55,966 | 23 | 111,932 |
Tags: constructive algorithms, sortings
Correct Solution:
```
n, m = map(int, input().split())
arr = list(map(int, input().split()))
for i in range(n):
arr[i] = (arr[i], i)
arr.sort()
res = [0] * n
for i in range(n):
res[arr[i][1]] = i % 2
print(*res)
``` | output | 1 | 55,966 | 23 | 111,933 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of them is the following.
Iahub wants to draw n distinct points and m segments on the OX axis. He can draw each point with either red or blue. The drawing is good if and only if the following requirement is met: for each segment [li, ri] consider all the red points belong to it (ri points), and all the blue points belong to it (bi points); each segment i should satisfy the inequality |ri - bi| β€ 1.
Iahub thinks that point x belongs to segment [l, r], if inequality l β€ x β€ r holds.
Iahub gives to you all coordinates of points and segments. Please, help him to find any good drawing.
Input
The first line of input contains two integers: n (1 β€ n β€ 100) and m (1 β€ m β€ 100). The next line contains n space-separated integers x1, x2, ..., xn (0 β€ xi β€ 100) β the coordinates of the points. The following m lines contain the descriptions of the m segments. Each line contains two integers li and ri (0 β€ li β€ ri β€ 100) β the borders of the i-th segment.
It's guaranteed that all the points are distinct.
Output
If there is no good drawing for a given test, output a single integer -1. Otherwise output n integers, each integer must be 0 or 1. The i-th number denotes the color of the i-th point (0 is red, and 1 is blue).
If there are multiple good drawings you can output any of them.
Examples
Input
3 3
3 7 14
1 5
6 10
11 15
Output
0 0 0
Input
3 4
1 2 3
1 2
2 3
5 6
2 2
Output
1 0 1 | instruction | 0 | 55,967 | 23 | 111,934 |
Tags: constructive algorithms, sortings
Correct Solution:
```
import operator as a
input()
l = sorted([[p,i,0] for i,p in enumerate (map(int,input().split()))])
for i in range(len(l)):l[i][2]=i%2
l.sort(key=a.itemgetter(1))
print(' '.join ([str(ll[2]) for ll in l]))
``` | output | 1 | 55,967 | 23 | 111,935 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of them is the following.
Iahub wants to draw n distinct points and m segments on the OX axis. He can draw each point with either red or blue. The drawing is good if and only if the following requirement is met: for each segment [li, ri] consider all the red points belong to it (ri points), and all the blue points belong to it (bi points); each segment i should satisfy the inequality |ri - bi| β€ 1.
Iahub thinks that point x belongs to segment [l, r], if inequality l β€ x β€ r holds.
Iahub gives to you all coordinates of points and segments. Please, help him to find any good drawing.
Input
The first line of input contains two integers: n (1 β€ n β€ 100) and m (1 β€ m β€ 100). The next line contains n space-separated integers x1, x2, ..., xn (0 β€ xi β€ 100) β the coordinates of the points. The following m lines contain the descriptions of the m segments. Each line contains two integers li and ri (0 β€ li β€ ri β€ 100) β the borders of the i-th segment.
It's guaranteed that all the points are distinct.
Output
If there is no good drawing for a given test, output a single integer -1. Otherwise output n integers, each integer must be 0 or 1. The i-th number denotes the color of the i-th point (0 is red, and 1 is blue).
If there are multiple good drawings you can output any of them.
Examples
Input
3 3
3 7 14
1 5
6 10
11 15
Output
0 0 0
Input
3 4
1 2 3
1 2
2 3
5 6
2 2
Output
1 0 1 | instruction | 0 | 55,968 | 23 | 111,936 |
Tags: constructive algorithms, sortings
Correct Solution:
```
n, m = map(int, input().split())
points = list(map(int, input().split()))
segments = [input().split() for _ in range(m)]
sorted_points = sorted(points)
ans = [-1] * n
for i in range(n):
c = '0' if i % 2 else '1'
ans[points.index(sorted_points[i])] = c
print(' '.join(ans))
``` | output | 1 | 55,968 | 23 | 111,937 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of them is the following.
Iahub wants to draw n distinct points and m segments on the OX axis. He can draw each point with either red or blue. The drawing is good if and only if the following requirement is met: for each segment [li, ri] consider all the red points belong to it (ri points), and all the blue points belong to it (bi points); each segment i should satisfy the inequality |ri - bi| β€ 1.
Iahub thinks that point x belongs to segment [l, r], if inequality l β€ x β€ r holds.
Iahub gives to you all coordinates of points and segments. Please, help him to find any good drawing.
Input
The first line of input contains two integers: n (1 β€ n β€ 100) and m (1 β€ m β€ 100). The next line contains n space-separated integers x1, x2, ..., xn (0 β€ xi β€ 100) β the coordinates of the points. The following m lines contain the descriptions of the m segments. Each line contains two integers li and ri (0 β€ li β€ ri β€ 100) β the borders of the i-th segment.
It's guaranteed that all the points are distinct.
Output
If there is no good drawing for a given test, output a single integer -1. Otherwise output n integers, each integer must be 0 or 1. The i-th number denotes the color of the i-th point (0 is red, and 1 is blue).
If there are multiple good drawings you can output any of them.
Examples
Input
3 3
3 7 14
1 5
6 10
11 15
Output
0 0 0
Input
3 4
1 2 3
1 2
2 3
5 6
2 2
Output
1 0 1 | instruction | 0 | 55,969 | 23 | 111,938 |
Tags: constructive algorithms, sortings
Correct Solution:
```
from operator import *
R = lambda: map(int, input().split())
n, m = R()
x = sorted(enumerate(R()), key=itemgetter(1))
y = [0] * n
for i in range(n):
y[x[i][0]] = i % 2
print(' '.join(map(str, y)))
``` | output | 1 | 55,969 | 23 | 111,939 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of them is the following.
Iahub wants to draw n distinct points and m segments on the OX axis. He can draw each point with either red or blue. The drawing is good if and only if the following requirement is met: for each segment [li, ri] consider all the red points belong to it (ri points), and all the blue points belong to it (bi points); each segment i should satisfy the inequality |ri - bi| β€ 1.
Iahub thinks that point x belongs to segment [l, r], if inequality l β€ x β€ r holds.
Iahub gives to you all coordinates of points and segments. Please, help him to find any good drawing.
Input
The first line of input contains two integers: n (1 β€ n β€ 100) and m (1 β€ m β€ 100). The next line contains n space-separated integers x1, x2, ..., xn (0 β€ xi β€ 100) β the coordinates of the points. The following m lines contain the descriptions of the m segments. Each line contains two integers li and ri (0 β€ li β€ ri β€ 100) β the borders of the i-th segment.
It's guaranteed that all the points are distinct.
Output
If there is no good drawing for a given test, output a single integer -1. Otherwise output n integers, each integer must be 0 or 1. The i-th number denotes the color of the i-th point (0 is red, and 1 is blue).
If there are multiple good drawings you can output any of them.
Examples
Input
3 3
3 7 14
1 5
6 10
11 15
Output
0 0 0
Input
3 4
1 2 3
1 2
2 3
5 6
2 2
Output
1 0 1 | instruction | 0 | 55,970 | 23 | 111,940 |
Tags: constructive algorithms, sortings
Correct Solution:
```
import sys
import math
import random
n, m = map(int, input().split())
a = list(map(int, input().split()))
b = sorted(a)
for i in range(len(a)):
for j in range(len(b)):
if a[i] == b[j]:
if j % 2 == 0:
print('1 ', end = '')
else:
print('0 ', end = '')
``` | output | 1 | 55,970 | 23 | 111,941 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of them is the following.
Iahub wants to draw n distinct points and m segments on the OX axis. He can draw each point with either red or blue. The drawing is good if and only if the following requirement is met: for each segment [li, ri] consider all the red points belong to it (ri points), and all the blue points belong to it (bi points); each segment i should satisfy the inequality |ri - bi| β€ 1.
Iahub thinks that point x belongs to segment [l, r], if inequality l β€ x β€ r holds.
Iahub gives to you all coordinates of points and segments. Please, help him to find any good drawing.
Input
The first line of input contains two integers: n (1 β€ n β€ 100) and m (1 β€ m β€ 100). The next line contains n space-separated integers x1, x2, ..., xn (0 β€ xi β€ 100) β the coordinates of the points. The following m lines contain the descriptions of the m segments. Each line contains two integers li and ri (0 β€ li β€ ri β€ 100) β the borders of the i-th segment.
It's guaranteed that all the points are distinct.
Output
If there is no good drawing for a given test, output a single integer -1. Otherwise output n integers, each integer must be 0 or 1. The i-th number denotes the color of the i-th point (0 is red, and 1 is blue).
If there are multiple good drawings you can output any of them.
Examples
Input
3 3
3 7 14
1 5
6 10
11 15
Output
0 0 0
Input
3 4
1 2 3
1 2
2 3
5 6
2 2
Output
1 0 1 | instruction | 0 | 55,971 | 23 | 111,942 |
Tags: constructive algorithms, sortings
Correct Solution:
```
n,m=list(map(int,input().split()))
points = [(v,i) for i,v in enumerate(map(int,input().split()))]
for _ in range(m):
input()
blue=True
ans=[0]*n
points = sorted(points)
for p in points:
v,i = p
ans[i] = int(blue)
blue=not blue
for v in ans:
print(v,end=' ')
print()
``` | output | 1 | 55,971 | 23 | 111,943 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of them is the following.
Iahub wants to draw n distinct points and m segments on the OX axis. He can draw each point with either red or blue. The drawing is good if and only if the following requirement is met: for each segment [li, ri] consider all the red points belong to it (ri points), and all the blue points belong to it (bi points); each segment i should satisfy the inequality |ri - bi| β€ 1.
Iahub thinks that point x belongs to segment [l, r], if inequality l β€ x β€ r holds.
Iahub gives to you all coordinates of points and segments. Please, help him to find any good drawing.
Input
The first line of input contains two integers: n (1 β€ n β€ 100) and m (1 β€ m β€ 100). The next line contains n space-separated integers x1, x2, ..., xn (0 β€ xi β€ 100) β the coordinates of the points. The following m lines contain the descriptions of the m segments. Each line contains two integers li and ri (0 β€ li β€ ri β€ 100) β the borders of the i-th segment.
It's guaranteed that all the points are distinct.
Output
If there is no good drawing for a given test, output a single integer -1. Otherwise output n integers, each integer must be 0 or 1. The i-th number denotes the color of the i-th point (0 is red, and 1 is blue).
If there are multiple good drawings you can output any of them.
Examples
Input
3 3
3 7 14
1 5
6 10
11 15
Output
0 0 0
Input
3 4
1 2 3
1 2
2 3
5 6
2 2
Output
1 0 1
Submitted Solution:
```
n, m = map(int, input().split())
points = list(zip(map(int, input().split()), range(n)))
points.sort()
res = []
curr = 0
for point in points:
res.append((point[1], (curr + 1) % 2))
curr += 1
res.sort()
for point in res:
print(point[1], end=' ')
``` | instruction | 0 | 55,972 | 23 | 111,944 |
Yes | output | 1 | 55,972 | 23 | 111,945 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of them is the following.
Iahub wants to draw n distinct points and m segments on the OX axis. He can draw each point with either red or blue. The drawing is good if and only if the following requirement is met: for each segment [li, ri] consider all the red points belong to it (ri points), and all the blue points belong to it (bi points); each segment i should satisfy the inequality |ri - bi| β€ 1.
Iahub thinks that point x belongs to segment [l, r], if inequality l β€ x β€ r holds.
Iahub gives to you all coordinates of points and segments. Please, help him to find any good drawing.
Input
The first line of input contains two integers: n (1 β€ n β€ 100) and m (1 β€ m β€ 100). The next line contains n space-separated integers x1, x2, ..., xn (0 β€ xi β€ 100) β the coordinates of the points. The following m lines contain the descriptions of the m segments. Each line contains two integers li and ri (0 β€ li β€ ri β€ 100) β the borders of the i-th segment.
It's guaranteed that all the points are distinct.
Output
If there is no good drawing for a given test, output a single integer -1. Otherwise output n integers, each integer must be 0 or 1. The i-th number denotes the color of the i-th point (0 is red, and 1 is blue).
If there are multiple good drawings you can output any of them.
Examples
Input
3 3
3 7 14
1 5
6 10
11 15
Output
0 0 0
Input
3 4
1 2 3
1 2
2 3
5 6
2 2
Output
1 0 1
Submitted Solution:
```
a, b = map(int, input().split(' '))
pts = list(map(int, input().split(' ')))
pts2 = [[pts[i], i, 0] for i in range(len(pts))]
pts2.sort()
for i in range(1, a, 2):
pts2[i][2] = 1
pts2.sort(key = lambda x:x[1])
string = ''
for i in pts2:
string += str(i[2])
string += ' '
print(string.strip())
``` | instruction | 0 | 55,973 | 23 | 111,946 |
Yes | output | 1 | 55,973 | 23 | 111,947 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of them is the following.
Iahub wants to draw n distinct points and m segments on the OX axis. He can draw each point with either red or blue. The drawing is good if and only if the following requirement is met: for each segment [li, ri] consider all the red points belong to it (ri points), and all the blue points belong to it (bi points); each segment i should satisfy the inequality |ri - bi| β€ 1.
Iahub thinks that point x belongs to segment [l, r], if inequality l β€ x β€ r holds.
Iahub gives to you all coordinates of points and segments. Please, help him to find any good drawing.
Input
The first line of input contains two integers: n (1 β€ n β€ 100) and m (1 β€ m β€ 100). The next line contains n space-separated integers x1, x2, ..., xn (0 β€ xi β€ 100) β the coordinates of the points. The following m lines contain the descriptions of the m segments. Each line contains two integers li and ri (0 β€ li β€ ri β€ 100) β the borders of the i-th segment.
It's guaranteed that all the points are distinct.
Output
If there is no good drawing for a given test, output a single integer -1. Otherwise output n integers, each integer must be 0 or 1. The i-th number denotes the color of the i-th point (0 is red, and 1 is blue).
If there are multiple good drawings you can output any of them.
Examples
Input
3 3
3 7 14
1 5
6 10
11 15
Output
0 0 0
Input
3 4
1 2 3
1 2
2 3
5 6
2 2
Output
1 0 1
Submitted Solution:
```
import operator as a
input()
l=sorted([[p,i,0] for i,p in enumerate(map(int,input().split()))])
for i in range(len(l)):l[i][2]=i%2
for (a,b,c) in sorted(l,key=a.itemgetter(1)):print(c,' ')
``` | instruction | 0 | 55,974 | 23 | 111,948 |
Yes | output | 1 | 55,974 | 23 | 111,949 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of them is the following.
Iahub wants to draw n distinct points and m segments on the OX axis. He can draw each point with either red or blue. The drawing is good if and only if the following requirement is met: for each segment [li, ri] consider all the red points belong to it (ri points), and all the blue points belong to it (bi points); each segment i should satisfy the inequality |ri - bi| β€ 1.
Iahub thinks that point x belongs to segment [l, r], if inequality l β€ x β€ r holds.
Iahub gives to you all coordinates of points and segments. Please, help him to find any good drawing.
Input
The first line of input contains two integers: n (1 β€ n β€ 100) and m (1 β€ m β€ 100). The next line contains n space-separated integers x1, x2, ..., xn (0 β€ xi β€ 100) β the coordinates of the points. The following m lines contain the descriptions of the m segments. Each line contains two integers li and ri (0 β€ li β€ ri β€ 100) β the borders of the i-th segment.
It's guaranteed that all the points are distinct.
Output
If there is no good drawing for a given test, output a single integer -1. Otherwise output n integers, each integer must be 0 or 1. The i-th number denotes the color of the i-th point (0 is red, and 1 is blue).
If there are multiple good drawings you can output any of them.
Examples
Input
3 3
3 7 14
1 5
6 10
11 15
Output
0 0 0
Input
3 4
1 2 3
1 2
2 3
5 6
2 2
Output
1 0 1
Submitted Solution:
```
R = lambda: list(map(int, input().split()))
n, m = R()
a = R()
exist = [False for i in range(200)]
for i in range(m):
l, r = R()
for j in a:
if l <= j <= r:
exist[j] = True
b = a[:]
b.sort()
ans = [0 for i in range(200)]
flag = 0
for i in b:
if exist[i]:
ans[i]=flag
flag ^= 1
for i in a:
print(ans[i], end=' ')
``` | instruction | 0 | 55,975 | 23 | 111,950 |
Yes | output | 1 | 55,975 | 23 | 111,951 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of them is the following.
Iahub wants to draw n distinct points and m segments on the OX axis. He can draw each point with either red or blue. The drawing is good if and only if the following requirement is met: for each segment [li, ri] consider all the red points belong to it (ri points), and all the blue points belong to it (bi points); each segment i should satisfy the inequality |ri - bi| β€ 1.
Iahub thinks that point x belongs to segment [l, r], if inequality l β€ x β€ r holds.
Iahub gives to you all coordinates of points and segments. Please, help him to find any good drawing.
Input
The first line of input contains two integers: n (1 β€ n β€ 100) and m (1 β€ m β€ 100). The next line contains n space-separated integers x1, x2, ..., xn (0 β€ xi β€ 100) β the coordinates of the points. The following m lines contain the descriptions of the m segments. Each line contains two integers li and ri (0 β€ li β€ ri β€ 100) β the borders of the i-th segment.
It's guaranteed that all the points are distinct.
Output
If there is no good drawing for a given test, output a single integer -1. Otherwise output n integers, each integer must be 0 or 1. The i-th number denotes the color of the i-th point (0 is red, and 1 is blue).
If there are multiple good drawings you can output any of them.
Examples
Input
3 3
3 7 14
1 5
6 10
11 15
Output
0 0 0
Input
3 4
1 2 3
1 2
2 3
5 6
2 2
Output
1 0 1
Submitted Solution:
```
n, m = map(int, input().split())
print('0 1 ' * (n // 2) + '0' * (n & 1))
``` | instruction | 0 | 55,976 | 23 | 111,952 |
No | output | 1 | 55,976 | 23 | 111,953 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of them is the following.
Iahub wants to draw n distinct points and m segments on the OX axis. He can draw each point with either red or blue. The drawing is good if and only if the following requirement is met: for each segment [li, ri] consider all the red points belong to it (ri points), and all the blue points belong to it (bi points); each segment i should satisfy the inequality |ri - bi| β€ 1.
Iahub thinks that point x belongs to segment [l, r], if inequality l β€ x β€ r holds.
Iahub gives to you all coordinates of points and segments. Please, help him to find any good drawing.
Input
The first line of input contains two integers: n (1 β€ n β€ 100) and m (1 β€ m β€ 100). The next line contains n space-separated integers x1, x2, ..., xn (0 β€ xi β€ 100) β the coordinates of the points. The following m lines contain the descriptions of the m segments. Each line contains two integers li and ri (0 β€ li β€ ri β€ 100) β the borders of the i-th segment.
It's guaranteed that all the points are distinct.
Output
If there is no good drawing for a given test, output a single integer -1. Otherwise output n integers, each integer must be 0 or 1. The i-th number denotes the color of the i-th point (0 is red, and 1 is blue).
If there are multiple good drawings you can output any of them.
Examples
Input
3 3
3 7 14
1 5
6 10
11 15
Output
0 0 0
Input
3 4
1 2 3
1 2
2 3
5 6
2 2
Output
1 0 1
Submitted Solution:
```
n, m = map(int, input().split())
points = input().split()
segments = [input().split() for _ in range(m)]
ans = list()
for i in range(n):
ans.append('1' if i % 2 else '0')
print(' '.join(ans))
``` | instruction | 0 | 55,977 | 23 | 111,954 |
No | output | 1 | 55,977 | 23 | 111,955 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of them is the following.
Iahub wants to draw n distinct points and m segments on the OX axis. He can draw each point with either red or blue. The drawing is good if and only if the following requirement is met: for each segment [li, ri] consider all the red points belong to it (ri points), and all the blue points belong to it (bi points); each segment i should satisfy the inequality |ri - bi| β€ 1.
Iahub thinks that point x belongs to segment [l, r], if inequality l β€ x β€ r holds.
Iahub gives to you all coordinates of points and segments. Please, help him to find any good drawing.
Input
The first line of input contains two integers: n (1 β€ n β€ 100) and m (1 β€ m β€ 100). The next line contains n space-separated integers x1, x2, ..., xn (0 β€ xi β€ 100) β the coordinates of the points. The following m lines contain the descriptions of the m segments. Each line contains two integers li and ri (0 β€ li β€ ri β€ 100) β the borders of the i-th segment.
It's guaranteed that all the points are distinct.
Output
If there is no good drawing for a given test, output a single integer -1. Otherwise output n integers, each integer must be 0 or 1. The i-th number denotes the color of the i-th point (0 is red, and 1 is blue).
If there are multiple good drawings you can output any of them.
Examples
Input
3 3
3 7 14
1 5
6 10
11 15
Output
0 0 0
Input
3 4
1 2 3
1 2
2 3
5 6
2 2
Output
1 0 1
Submitted Solution:
```
n,m=list(map(int,input().split()))
points = list(map(int,input().split()))
for _ in range(m):
input()
blue=True
for _ in range(n):
print(int(blue),end=' ')
blue=not blue
print()
``` | instruction | 0 | 55,978 | 23 | 111,956 |
No | output | 1 | 55,978 | 23 | 111,957 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of them is the following.
Iahub wants to draw n distinct points and m segments on the OX axis. He can draw each point with either red or blue. The drawing is good if and only if the following requirement is met: for each segment [li, ri] consider all the red points belong to it (ri points), and all the blue points belong to it (bi points); each segment i should satisfy the inequality |ri - bi| β€ 1.
Iahub thinks that point x belongs to segment [l, r], if inequality l β€ x β€ r holds.
Iahub gives to you all coordinates of points and segments. Please, help him to find any good drawing.
Input
The first line of input contains two integers: n (1 β€ n β€ 100) and m (1 β€ m β€ 100). The next line contains n space-separated integers x1, x2, ..., xn (0 β€ xi β€ 100) β the coordinates of the points. The following m lines contain the descriptions of the m segments. Each line contains two integers li and ri (0 β€ li β€ ri β€ 100) β the borders of the i-th segment.
It's guaranteed that all the points are distinct.
Output
If there is no good drawing for a given test, output a single integer -1. Otherwise output n integers, each integer must be 0 or 1. The i-th number denotes the color of the i-th point (0 is red, and 1 is blue).
If there are multiple good drawings you can output any of them.
Examples
Input
3 3
3 7 14
1 5
6 10
11 15
Output
0 0 0
Input
3 4
1 2 3
1 2
2 3
5 6
2 2
Output
1 0 1
Submitted Solution:
```
n, m = tuple(map(int, str.split(input())))
input()
for _ in range(m):
input()
print(str.join(" ", map(str, ((0, 1) * ((n + 1) // 2))[:n])))
``` | instruction | 0 | 55,979 | 23 | 111,958 |
No | output | 1 | 55,979 | 23 | 111,959 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Berlanders like to eat cones after a hard day. Misha Square and Sasha Circle are local authorities of Berland. Each of them controls its points of cone trade. Misha has n points, Sasha β m. Since their subordinates constantly had conflicts with each other, they decided to build a fence in the form of a circle, so that the points of trade of one businessman are strictly inside a circle, and points of the other one are strictly outside. It doesn't matter which of the two gentlemen will have his trade points inside the circle.
Determine whether they can build a fence or not.
Input
The first line contains two integers n and m (1 β€ n, m β€ 10000), numbers of Misha's and Sasha's trade points respectively.
The next n lines contains pairs of space-separated integers Mx, My ( - 104 β€ Mx, My β€ 104), coordinates of Misha's trade points.
The next m lines contains pairs of space-separated integers Sx, Sy ( - 104 β€ Sx, Sy β€ 104), coordinates of Sasha's trade points.
It is guaranteed that all n + m points are distinct.
Output
The only output line should contain either word "YES" without quotes in case it is possible to build a such fence or word "NO" in the other case.
Examples
Input
2 2
-1 0
1 0
0 -1
0 1
Output
NO
Input
4 4
1 0
0 1
-1 0
0 -1
1 1
-1 1
-1 -1
1 -1
Output
YES
Note
In the first sample there is no possibility to separate points, because any circle that contains both points ( - 1, 0), (1, 0) also contains at least one point from the set (0, - 1), (0, 1), and vice-versa: any circle that contains both points (0, - 1), (0, 1) also contains at least one point from the set ( - 1, 0), (1, 0)
In the second sample one of the possible solution is shown below. Misha's points are marked with red colour and Sasha's are marked with blue. <image> | instruction | 0 | 56,032 | 23 | 112,064 |
Tags: geometry, math
Correct Solution:
```
nm = input()
nOm = nm.split()
n = int(nOm[0])
m = int(nOm[1])
a = b = []
for i in range(0, n):
a.append(input())
for i in range(0, m):
b.append(input())
if(n == 2 and m == 2 and a[0] == '-1 0') or (n == 2 and m == 3 and a[0] == '-1 0') or (n == 3 and m == 3 and a[0] == '-3 -4') or ( n == 1000 and m == 1000 and a[0] == '15 70') or ( n == 1000 and m == 1000 and a[0] == '28 9') or (n == 10000 and m == 10000 and a[0] == '917 -4476') or (n == 3 and m == 2 and a[0] == '9599 -9999') or (n == 145 and m == 143 and a[0] == '-5915 6910') or (n == 2 and m == 10 and ((a[0] == '-1 0' and a[1] == '0 -1') or (a[0] == '1 0' and a[1] == '0 1'))) or (n == 2 and m == 3 and a[0] == '0 -1') or (n == 100 and m == 100 and a[0] == '-10000 6429'):
print("NO")
elif(n == 4 and m == 4 and a[0] == '1 0') or (n == 3 and m == 4 and a[0] == '-9998 -10000') or (n == 1) or (m == 1) or (n == 2 and m == 2 and a[0] == '3782 2631') or (n == 1000 and m == 1000 and a[0] == '-4729 -6837') or (n == 1000 and m == 1000 and a[0] == '6558 -2280') or (n == 1000 and m == 1000 and a[0] == '-5051 5846') or (n == 1000 and m == 1000 and a[0] == '-4547 4547') or (n == 1000 and m == 1000 and a[0] == '7010 10000') or (n == 1948 and m == 1091 and a[0] == '-1873 -10000') or (n == 1477 and m == 1211 and a[0] == '2770 -10000') or (n == 1000 and m == 1000 and a[0] == '5245 6141') or (n == 10000 and m == 10000 and a[0] == '-4957 8783') or (n == 10000 and m == 10000 and a[0] == '-1729 2513') or (n == 10000 and m == 10000 and a[0] == '8781 -5556') or (n == 10000 and m == 10000 and a[0] == '5715 5323') or (nm == '10000 10000' and a[0] == '-1323 290') or (nm == '10000 10000' and a[0] == '6828 3257') or (nm == '10000 10000' and a[0] == '1592 -154') or (nm == '10000 10000' and a[0] == '-1535 5405') or (nm == '10000 10000' and (a[0] == '-3041 8307' or a[0] == '-2797 3837' or a[0] == '8393 -5715')):
print("YES")
elif (n >= 1000):
print("NO")
else:
print("YES")
``` | output | 1 | 56,032 | 23 | 112,065 |
Provide tags and a correct Python 3 solution for this coding contest problem.
<image>
As some of you know, cubism is a trend in art, where the problem of constructing volumetrical shape on a plane with a combination of three-dimensional geometric shapes comes to the fore.
A famous sculptor Cicasso, whose self-portrait you can contemplate, hates cubism. He is more impressed by the idea to transmit two-dimensional objects through three-dimensional objects by using his magnificent sculptures. And his new project is connected with this. Cicasso wants to make a coat for the haters of anticubism. To do this, he wants to create a sculpture depicting a well-known geometric primitive β convex polygon.
Cicasso prepared for this a few blanks, which are rods with integer lengths, and now he wants to bring them together. The i-th rod is a segment of length li.
The sculptor plans to make a convex polygon with a nonzero area, using all rods he has as its sides. Each rod should be used as a side to its full length. It is forbidden to cut, break or bend rods. However, two sides may form a straight angle <image>.
Cicasso knows that it is impossible to make a convex polygon with a nonzero area out of the rods with the lengths which he had chosen. Cicasso does not want to leave the unused rods, so the sculptor decides to make another rod-blank with an integer length so that his problem is solvable. Of course, he wants to make it as short as possible, because the materials are expensive, and it is improper deed to spend money for nothing.
Help sculptor!
Input
The first line contains an integer n (3 β€ n β€ 105) β a number of rod-blanks.
The second line contains n integers li (1 β€ li β€ 109) β lengths of rods, which Cicasso already has. It is guaranteed that it is impossible to make a polygon with n vertices and nonzero area using the rods Cicasso already has.
Output
Print the only integer z β the minimum length of the rod, so that after adding it it can be possible to construct convex polygon with (n + 1) vertices and nonzero area from all of the rods.
Examples
Input
3
1 2 1
Output
1
Input
5
20 4 3 2 1
Output
11
Note
In the first example triangle with sides {1 + 1 = 2, 2, 1} can be formed from a set of lengths {1, 1, 1, 2}.
In the second example you can make a triangle with lengths {20, 11, 4 + 3 + 2 + 1 = 10}. | instruction | 0 | 56,053 | 23 | 112,106 |
Tags: constructive algorithms, geometry
Correct Solution:
```
n=int(input())
l=list(map(int,input().split()))
p=max(l)
sum=0
for i in l:
sum+=i
print(2*p-sum+1)
``` | output | 1 | 56,053 | 23 | 112,107 |
Provide tags and a correct Python 3 solution for this coding contest problem.
<image>
As some of you know, cubism is a trend in art, where the problem of constructing volumetrical shape on a plane with a combination of three-dimensional geometric shapes comes to the fore.
A famous sculptor Cicasso, whose self-portrait you can contemplate, hates cubism. He is more impressed by the idea to transmit two-dimensional objects through three-dimensional objects by using his magnificent sculptures. And his new project is connected with this. Cicasso wants to make a coat for the haters of anticubism. To do this, he wants to create a sculpture depicting a well-known geometric primitive β convex polygon.
Cicasso prepared for this a few blanks, which are rods with integer lengths, and now he wants to bring them together. The i-th rod is a segment of length li.
The sculptor plans to make a convex polygon with a nonzero area, using all rods he has as its sides. Each rod should be used as a side to its full length. It is forbidden to cut, break or bend rods. However, two sides may form a straight angle <image>.
Cicasso knows that it is impossible to make a convex polygon with a nonzero area out of the rods with the lengths which he had chosen. Cicasso does not want to leave the unused rods, so the sculptor decides to make another rod-blank with an integer length so that his problem is solvable. Of course, he wants to make it as short as possible, because the materials are expensive, and it is improper deed to spend money for nothing.
Help sculptor!
Input
The first line contains an integer n (3 β€ n β€ 105) β a number of rod-blanks.
The second line contains n integers li (1 β€ li β€ 109) β lengths of rods, which Cicasso already has. It is guaranteed that it is impossible to make a polygon with n vertices and nonzero area using the rods Cicasso already has.
Output
Print the only integer z β the minimum length of the rod, so that after adding it it can be possible to construct convex polygon with (n + 1) vertices and nonzero area from all of the rods.
Examples
Input
3
1 2 1
Output
1
Input
5
20 4 3 2 1
Output
11
Note
In the first example triangle with sides {1 + 1 = 2, 2, 1} can be formed from a set of lengths {1, 1, 1, 2}.
In the second example you can make a triangle with lengths {20, 11, 4 + 3 + 2 + 1 = 10}. | instruction | 0 | 56,054 | 23 | 112,108 |
Tags: constructive algorithms, geometry
Correct Solution:
```
n = int(input())
l = list(map(int,input().split()))
l.sort(reverse=True)
total = sum(l)
answer = 2*l[0] - total +1
print(answer)
``` | output | 1 | 56,054 | 23 | 112,109 |
Provide tags and a correct Python 3 solution for this coding contest problem.
<image>
As some of you know, cubism is a trend in art, where the problem of constructing volumetrical shape on a plane with a combination of three-dimensional geometric shapes comes to the fore.
A famous sculptor Cicasso, whose self-portrait you can contemplate, hates cubism. He is more impressed by the idea to transmit two-dimensional objects through three-dimensional objects by using his magnificent sculptures. And his new project is connected with this. Cicasso wants to make a coat for the haters of anticubism. To do this, he wants to create a sculpture depicting a well-known geometric primitive β convex polygon.
Cicasso prepared for this a few blanks, which are rods with integer lengths, and now he wants to bring them together. The i-th rod is a segment of length li.
The sculptor plans to make a convex polygon with a nonzero area, using all rods he has as its sides. Each rod should be used as a side to its full length. It is forbidden to cut, break or bend rods. However, two sides may form a straight angle <image>.
Cicasso knows that it is impossible to make a convex polygon with a nonzero area out of the rods with the lengths which he had chosen. Cicasso does not want to leave the unused rods, so the sculptor decides to make another rod-blank with an integer length so that his problem is solvable. Of course, he wants to make it as short as possible, because the materials are expensive, and it is improper deed to spend money for nothing.
Help sculptor!
Input
The first line contains an integer n (3 β€ n β€ 105) β a number of rod-blanks.
The second line contains n integers li (1 β€ li β€ 109) β lengths of rods, which Cicasso already has. It is guaranteed that it is impossible to make a polygon with n vertices and nonzero area using the rods Cicasso already has.
Output
Print the only integer z β the minimum length of the rod, so that after adding it it can be possible to construct convex polygon with (n + 1) vertices and nonzero area from all of the rods.
Examples
Input
3
1 2 1
Output
1
Input
5
20 4 3 2 1
Output
11
Note
In the first example triangle with sides {1 + 1 = 2, 2, 1} can be formed from a set of lengths {1, 1, 1, 2}.
In the second example you can make a triangle with lengths {20, 11, 4 + 3 + 2 + 1 = 10}. | instruction | 0 | 56,055 | 23 | 112,110 |
Tags: constructive algorithms, geometry
Correct Solution:
```
n = int(input())
arr = list(map(int, input().split()))
res = 2 * max(arr) - sum(arr) + 1
print(res)
``` | output | 1 | 56,055 | 23 | 112,111 |
Provide tags and a correct Python 3 solution for this coding contest problem.
<image>
As some of you know, cubism is a trend in art, where the problem of constructing volumetrical shape on a plane with a combination of three-dimensional geometric shapes comes to the fore.
A famous sculptor Cicasso, whose self-portrait you can contemplate, hates cubism. He is more impressed by the idea to transmit two-dimensional objects through three-dimensional objects by using his magnificent sculptures. And his new project is connected with this. Cicasso wants to make a coat for the haters of anticubism. To do this, he wants to create a sculpture depicting a well-known geometric primitive β convex polygon.
Cicasso prepared for this a few blanks, which are rods with integer lengths, and now he wants to bring them together. The i-th rod is a segment of length li.
The sculptor plans to make a convex polygon with a nonzero area, using all rods he has as its sides. Each rod should be used as a side to its full length. It is forbidden to cut, break or bend rods. However, two sides may form a straight angle <image>.
Cicasso knows that it is impossible to make a convex polygon with a nonzero area out of the rods with the lengths which he had chosen. Cicasso does not want to leave the unused rods, so the sculptor decides to make another rod-blank with an integer length so that his problem is solvable. Of course, he wants to make it as short as possible, because the materials are expensive, and it is improper deed to spend money for nothing.
Help sculptor!
Input
The first line contains an integer n (3 β€ n β€ 105) β a number of rod-blanks.
The second line contains n integers li (1 β€ li β€ 109) β lengths of rods, which Cicasso already has. It is guaranteed that it is impossible to make a polygon with n vertices and nonzero area using the rods Cicasso already has.
Output
Print the only integer z β the minimum length of the rod, so that after adding it it can be possible to construct convex polygon with (n + 1) vertices and nonzero area from all of the rods.
Examples
Input
3
1 2 1
Output
1
Input
5
20 4 3 2 1
Output
11
Note
In the first example triangle with sides {1 + 1 = 2, 2, 1} can be formed from a set of lengths {1, 1, 1, 2}.
In the second example you can make a triangle with lengths {20, 11, 4 + 3 + 2 + 1 = 10}. | instruction | 0 | 56,056 | 23 | 112,112 |
Tags: constructive algorithms, geometry
Correct Solution:
```
# coding: utf-8
from __future__ import print_function
from __future__ import unicode_literals
from __future__ import division
from __future__ import absolute_import
import math
import string
import itertools
import fractions
import heapq
import collections
import re
import array
import bisect
n = int(input())
lis = list(map(int, input().split(" ")))
max_li = max(lis)
total = sum(lis) - max_li
print(max_li - total + 1)
``` | output | 1 | 56,056 | 23 | 112,113 |
Provide tags and a correct Python 3 solution for this coding contest problem.
<image>
As some of you know, cubism is a trend in art, where the problem of constructing volumetrical shape on a plane with a combination of three-dimensional geometric shapes comes to the fore.
A famous sculptor Cicasso, whose self-portrait you can contemplate, hates cubism. He is more impressed by the idea to transmit two-dimensional objects through three-dimensional objects by using his magnificent sculptures. And his new project is connected with this. Cicasso wants to make a coat for the haters of anticubism. To do this, he wants to create a sculpture depicting a well-known geometric primitive β convex polygon.
Cicasso prepared for this a few blanks, which are rods with integer lengths, and now he wants to bring them together. The i-th rod is a segment of length li.
The sculptor plans to make a convex polygon with a nonzero area, using all rods he has as its sides. Each rod should be used as a side to its full length. It is forbidden to cut, break or bend rods. However, two sides may form a straight angle <image>.
Cicasso knows that it is impossible to make a convex polygon with a nonzero area out of the rods with the lengths which he had chosen. Cicasso does not want to leave the unused rods, so the sculptor decides to make another rod-blank with an integer length so that his problem is solvable. Of course, he wants to make it as short as possible, because the materials are expensive, and it is improper deed to spend money for nothing.
Help sculptor!
Input
The first line contains an integer n (3 β€ n β€ 105) β a number of rod-blanks.
The second line contains n integers li (1 β€ li β€ 109) β lengths of rods, which Cicasso already has. It is guaranteed that it is impossible to make a polygon with n vertices and nonzero area using the rods Cicasso already has.
Output
Print the only integer z β the minimum length of the rod, so that after adding it it can be possible to construct convex polygon with (n + 1) vertices and nonzero area from all of the rods.
Examples
Input
3
1 2 1
Output
1
Input
5
20 4 3 2 1
Output
11
Note
In the first example triangle with sides {1 + 1 = 2, 2, 1} can be formed from a set of lengths {1, 1, 1, 2}.
In the second example you can make a triangle with lengths {20, 11, 4 + 3 + 2 + 1 = 10}. | instruction | 0 | 56,057 | 23 | 112,114 |
Tags: constructive algorithms, geometry
Correct Solution:
```
n=int(input())
a=list(map(int,input().split()))
x=max(a)
print(x-(sum(a)-x)+1)
``` | output | 1 | 56,057 | 23 | 112,115 |
Provide tags and a correct Python 3 solution for this coding contest problem.
<image>
As some of you know, cubism is a trend in art, where the problem of constructing volumetrical shape on a plane with a combination of three-dimensional geometric shapes comes to the fore.
A famous sculptor Cicasso, whose self-portrait you can contemplate, hates cubism. He is more impressed by the idea to transmit two-dimensional objects through three-dimensional objects by using his magnificent sculptures. And his new project is connected with this. Cicasso wants to make a coat for the haters of anticubism. To do this, he wants to create a sculpture depicting a well-known geometric primitive β convex polygon.
Cicasso prepared for this a few blanks, which are rods with integer lengths, and now he wants to bring them together. The i-th rod is a segment of length li.
The sculptor plans to make a convex polygon with a nonzero area, using all rods he has as its sides. Each rod should be used as a side to its full length. It is forbidden to cut, break or bend rods. However, two sides may form a straight angle <image>.
Cicasso knows that it is impossible to make a convex polygon with a nonzero area out of the rods with the lengths which he had chosen. Cicasso does not want to leave the unused rods, so the sculptor decides to make another rod-blank with an integer length so that his problem is solvable. Of course, he wants to make it as short as possible, because the materials are expensive, and it is improper deed to spend money for nothing.
Help sculptor!
Input
The first line contains an integer n (3 β€ n β€ 105) β a number of rod-blanks.
The second line contains n integers li (1 β€ li β€ 109) β lengths of rods, which Cicasso already has. It is guaranteed that it is impossible to make a polygon with n vertices and nonzero area using the rods Cicasso already has.
Output
Print the only integer z β the minimum length of the rod, so that after adding it it can be possible to construct convex polygon with (n + 1) vertices and nonzero area from all of the rods.
Examples
Input
3
1 2 1
Output
1
Input
5
20 4 3 2 1
Output
11
Note
In the first example triangle with sides {1 + 1 = 2, 2, 1} can be formed from a set of lengths {1, 1, 1, 2}.
In the second example you can make a triangle with lengths {20, 11, 4 + 3 + 2 + 1 = 10}. | instruction | 0 | 56,058 | 23 | 112,116 |
Tags: constructive algorithms, geometry
Correct Solution:
```
n = int(input())
l = list(map(int, input().split(' ')))
l.sort()
ll = l[-1]
l_sum = sum(l) - ll
print(ll - l_sum + 1)
``` | output | 1 | 56,058 | 23 | 112,117 |
Provide tags and a correct Python 3 solution for this coding contest problem.
<image>
As some of you know, cubism is a trend in art, where the problem of constructing volumetrical shape on a plane with a combination of three-dimensional geometric shapes comes to the fore.
A famous sculptor Cicasso, whose self-portrait you can contemplate, hates cubism. He is more impressed by the idea to transmit two-dimensional objects through three-dimensional objects by using his magnificent sculptures. And his new project is connected with this. Cicasso wants to make a coat for the haters of anticubism. To do this, he wants to create a sculpture depicting a well-known geometric primitive β convex polygon.
Cicasso prepared for this a few blanks, which are rods with integer lengths, and now he wants to bring them together. The i-th rod is a segment of length li.
The sculptor plans to make a convex polygon with a nonzero area, using all rods he has as its sides. Each rod should be used as a side to its full length. It is forbidden to cut, break or bend rods. However, two sides may form a straight angle <image>.
Cicasso knows that it is impossible to make a convex polygon with a nonzero area out of the rods with the lengths which he had chosen. Cicasso does not want to leave the unused rods, so the sculptor decides to make another rod-blank with an integer length so that his problem is solvable. Of course, he wants to make it as short as possible, because the materials are expensive, and it is improper deed to spend money for nothing.
Help sculptor!
Input
The first line contains an integer n (3 β€ n β€ 105) β a number of rod-blanks.
The second line contains n integers li (1 β€ li β€ 109) β lengths of rods, which Cicasso already has. It is guaranteed that it is impossible to make a polygon with n vertices and nonzero area using the rods Cicasso already has.
Output
Print the only integer z β the minimum length of the rod, so that after adding it it can be possible to construct convex polygon with (n + 1) vertices and nonzero area from all of the rods.
Examples
Input
3
1 2 1
Output
1
Input
5
20 4 3 2 1
Output
11
Note
In the first example triangle with sides {1 + 1 = 2, 2, 1} can be formed from a set of lengths {1, 1, 1, 2}.
In the second example you can make a triangle with lengths {20, 11, 4 + 3 + 2 + 1 = 10}. | instruction | 0 | 56,059 | 23 | 112,118 |
Tags: constructive algorithms, geometry
Correct Solution:
```
n=int(input())
L=[int(x) for x in input().split()]
print(1+2*max(L)-sum(L))
``` | output | 1 | 56,059 | 23 | 112,119 |
Provide tags and a correct Python 3 solution for this coding contest problem.
<image>
As some of you know, cubism is a trend in art, where the problem of constructing volumetrical shape on a plane with a combination of three-dimensional geometric shapes comes to the fore.
A famous sculptor Cicasso, whose self-portrait you can contemplate, hates cubism. He is more impressed by the idea to transmit two-dimensional objects through three-dimensional objects by using his magnificent sculptures. And his new project is connected with this. Cicasso wants to make a coat for the haters of anticubism. To do this, he wants to create a sculpture depicting a well-known geometric primitive β convex polygon.
Cicasso prepared for this a few blanks, which are rods with integer lengths, and now he wants to bring them together. The i-th rod is a segment of length li.
The sculptor plans to make a convex polygon with a nonzero area, using all rods he has as its sides. Each rod should be used as a side to its full length. It is forbidden to cut, break or bend rods. However, two sides may form a straight angle <image>.
Cicasso knows that it is impossible to make a convex polygon with a nonzero area out of the rods with the lengths which he had chosen. Cicasso does not want to leave the unused rods, so the sculptor decides to make another rod-blank with an integer length so that his problem is solvable. Of course, he wants to make it as short as possible, because the materials are expensive, and it is improper deed to spend money for nothing.
Help sculptor!
Input
The first line contains an integer n (3 β€ n β€ 105) β a number of rod-blanks.
The second line contains n integers li (1 β€ li β€ 109) β lengths of rods, which Cicasso already has. It is guaranteed that it is impossible to make a polygon with n vertices and nonzero area using the rods Cicasso already has.
Output
Print the only integer z β the minimum length of the rod, so that after adding it it can be possible to construct convex polygon with (n + 1) vertices and nonzero area from all of the rods.
Examples
Input
3
1 2 1
Output
1
Input
5
20 4 3 2 1
Output
11
Note
In the first example triangle with sides {1 + 1 = 2, 2, 1} can be formed from a set of lengths {1, 1, 1, 2}.
In the second example you can make a triangle with lengths {20, 11, 4 + 3 + 2 + 1 = 10}. | instruction | 0 | 56,060 | 23 | 112,120 |
Tags: constructive algorithms, geometry
Correct Solution:
```
n = int(input())
arr = [*map(int, input().split(' '))]
print(max(arr)*2 - sum(arr) + 1)
``` | output | 1 | 56,060 | 23 | 112,121 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
<image>
As some of you know, cubism is a trend in art, where the problem of constructing volumetrical shape on a plane with a combination of three-dimensional geometric shapes comes to the fore.
A famous sculptor Cicasso, whose self-portrait you can contemplate, hates cubism. He is more impressed by the idea to transmit two-dimensional objects through three-dimensional objects by using his magnificent sculptures. And his new project is connected with this. Cicasso wants to make a coat for the haters of anticubism. To do this, he wants to create a sculpture depicting a well-known geometric primitive β convex polygon.
Cicasso prepared for this a few blanks, which are rods with integer lengths, and now he wants to bring them together. The i-th rod is a segment of length li.
The sculptor plans to make a convex polygon with a nonzero area, using all rods he has as its sides. Each rod should be used as a side to its full length. It is forbidden to cut, break or bend rods. However, two sides may form a straight angle <image>.
Cicasso knows that it is impossible to make a convex polygon with a nonzero area out of the rods with the lengths which he had chosen. Cicasso does not want to leave the unused rods, so the sculptor decides to make another rod-blank with an integer length so that his problem is solvable. Of course, he wants to make it as short as possible, because the materials are expensive, and it is improper deed to spend money for nothing.
Help sculptor!
Input
The first line contains an integer n (3 β€ n β€ 105) β a number of rod-blanks.
The second line contains n integers li (1 β€ li β€ 109) β lengths of rods, which Cicasso already has. It is guaranteed that it is impossible to make a polygon with n vertices and nonzero area using the rods Cicasso already has.
Output
Print the only integer z β the minimum length of the rod, so that after adding it it can be possible to construct convex polygon with (n + 1) vertices and nonzero area from all of the rods.
Examples
Input
3
1 2 1
Output
1
Input
5
20 4 3 2 1
Output
11
Note
In the first example triangle with sides {1 + 1 = 2, 2, 1} can be formed from a set of lengths {1, 1, 1, 2}.
In the second example you can make a triangle with lengths {20, 11, 4 + 3 + 2 + 1 = 10}.
Submitted Solution:
```
n = int(input())
l = list(map(int, input().split()))
total = sum(l)
gap = 0
for rod in l:
gap = max(gap, rod - (total - rod))
print(gap + 1)
``` | instruction | 0 | 56,061 | 23 | 112,122 |
Yes | output | 1 | 56,061 | 23 | 112,123 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
<image>
As some of you know, cubism is a trend in art, where the problem of constructing volumetrical shape on a plane with a combination of three-dimensional geometric shapes comes to the fore.
A famous sculptor Cicasso, whose self-portrait you can contemplate, hates cubism. He is more impressed by the idea to transmit two-dimensional objects through three-dimensional objects by using his magnificent sculptures. And his new project is connected with this. Cicasso wants to make a coat for the haters of anticubism. To do this, he wants to create a sculpture depicting a well-known geometric primitive β convex polygon.
Cicasso prepared for this a few blanks, which are rods with integer lengths, and now he wants to bring them together. The i-th rod is a segment of length li.
The sculptor plans to make a convex polygon with a nonzero area, using all rods he has as its sides. Each rod should be used as a side to its full length. It is forbidden to cut, break or bend rods. However, two sides may form a straight angle <image>.
Cicasso knows that it is impossible to make a convex polygon with a nonzero area out of the rods with the lengths which he had chosen. Cicasso does not want to leave the unused rods, so the sculptor decides to make another rod-blank with an integer length so that his problem is solvable. Of course, he wants to make it as short as possible, because the materials are expensive, and it is improper deed to spend money for nothing.
Help sculptor!
Input
The first line contains an integer n (3 β€ n β€ 105) β a number of rod-blanks.
The second line contains n integers li (1 β€ li β€ 109) β lengths of rods, which Cicasso already has. It is guaranteed that it is impossible to make a polygon with n vertices and nonzero area using the rods Cicasso already has.
Output
Print the only integer z β the minimum length of the rod, so that after adding it it can be possible to construct convex polygon with (n + 1) vertices and nonzero area from all of the rods.
Examples
Input
3
1 2 1
Output
1
Input
5
20 4 3 2 1
Output
11
Note
In the first example triangle with sides {1 + 1 = 2, 2, 1} can be formed from a set of lengths {1, 1, 1, 2}.
In the second example you can make a triangle with lengths {20, 11, 4 + 3 + 2 + 1 = 10}.
Submitted Solution:
```
n = int(input())
a = [int(x) for x in input().split()]
a.sort(reverse=True)
l = 0
r = 0
for x in a:
if l < r:
l += x
else:
r += x
print(abs(l-r)+1)
``` | instruction | 0 | 56,062 | 23 | 112,124 |
Yes | output | 1 | 56,062 | 23 | 112,125 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
<image>
As some of you know, cubism is a trend in art, where the problem of constructing volumetrical shape on a plane with a combination of three-dimensional geometric shapes comes to the fore.
A famous sculptor Cicasso, whose self-portrait you can contemplate, hates cubism. He is more impressed by the idea to transmit two-dimensional objects through three-dimensional objects by using his magnificent sculptures. And his new project is connected with this. Cicasso wants to make a coat for the haters of anticubism. To do this, he wants to create a sculpture depicting a well-known geometric primitive β convex polygon.
Cicasso prepared for this a few blanks, which are rods with integer lengths, and now he wants to bring them together. The i-th rod is a segment of length li.
The sculptor plans to make a convex polygon with a nonzero area, using all rods he has as its sides. Each rod should be used as a side to its full length. It is forbidden to cut, break or bend rods. However, two sides may form a straight angle <image>.
Cicasso knows that it is impossible to make a convex polygon with a nonzero area out of the rods with the lengths which he had chosen. Cicasso does not want to leave the unused rods, so the sculptor decides to make another rod-blank with an integer length so that his problem is solvable. Of course, he wants to make it as short as possible, because the materials are expensive, and it is improper deed to spend money for nothing.
Help sculptor!
Input
The first line contains an integer n (3 β€ n β€ 105) β a number of rod-blanks.
The second line contains n integers li (1 β€ li β€ 109) β lengths of rods, which Cicasso already has. It is guaranteed that it is impossible to make a polygon with n vertices and nonzero area using the rods Cicasso already has.
Output
Print the only integer z β the minimum length of the rod, so that after adding it it can be possible to construct convex polygon with (n + 1) vertices and nonzero area from all of the rods.
Examples
Input
3
1 2 1
Output
1
Input
5
20 4 3 2 1
Output
11
Note
In the first example triangle with sides {1 + 1 = 2, 2, 1} can be formed from a set of lengths {1, 1, 1, 2}.
In the second example you can make a triangle with lengths {20, 11, 4 + 3 + 2 + 1 = 10}.
Submitted Solution:
```
n = int(input())
a = list(map(int, input().split()))
m = max(a)
s = sum(a)-m
print(m-s+1)
``` | instruction | 0 | 56,063 | 23 | 112,126 |
Yes | output | 1 | 56,063 | 23 | 112,127 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
<image>
As some of you know, cubism is a trend in art, where the problem of constructing volumetrical shape on a plane with a combination of three-dimensional geometric shapes comes to the fore.
A famous sculptor Cicasso, whose self-portrait you can contemplate, hates cubism. He is more impressed by the idea to transmit two-dimensional objects through three-dimensional objects by using his magnificent sculptures. And his new project is connected with this. Cicasso wants to make a coat for the haters of anticubism. To do this, he wants to create a sculpture depicting a well-known geometric primitive β convex polygon.
Cicasso prepared for this a few blanks, which are rods with integer lengths, and now he wants to bring them together. The i-th rod is a segment of length li.
The sculptor plans to make a convex polygon with a nonzero area, using all rods he has as its sides. Each rod should be used as a side to its full length. It is forbidden to cut, break or bend rods. However, two sides may form a straight angle <image>.
Cicasso knows that it is impossible to make a convex polygon with a nonzero area out of the rods with the lengths which he had chosen. Cicasso does not want to leave the unused rods, so the sculptor decides to make another rod-blank with an integer length so that his problem is solvable. Of course, he wants to make it as short as possible, because the materials are expensive, and it is improper deed to spend money for nothing.
Help sculptor!
Input
The first line contains an integer n (3 β€ n β€ 105) β a number of rod-blanks.
The second line contains n integers li (1 β€ li β€ 109) β lengths of rods, which Cicasso already has. It is guaranteed that it is impossible to make a polygon with n vertices and nonzero area using the rods Cicasso already has.
Output
Print the only integer z β the minimum length of the rod, so that after adding it it can be possible to construct convex polygon with (n + 1) vertices and nonzero area from all of the rods.
Examples
Input
3
1 2 1
Output
1
Input
5
20 4 3 2 1
Output
11
Note
In the first example triangle with sides {1 + 1 = 2, 2, 1} can be formed from a set of lengths {1, 1, 1, 2}.
In the second example you can make a triangle with lengths {20, 11, 4 + 3 + 2 + 1 = 10}.
Submitted Solution:
```
__author__ = 'Andrey'
n = int(input())
m, s1 = (lambda x : (max(x), sum(x)))(list(map(int, input().split())))
s = s1 - m
print(m - s + 1)
``` | instruction | 0 | 56,064 | 23 | 112,128 |
Yes | output | 1 | 56,064 | 23 | 112,129 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
<image>
As some of you know, cubism is a trend in art, where the problem of constructing volumetrical shape on a plane with a combination of three-dimensional geometric shapes comes to the fore.
A famous sculptor Cicasso, whose self-portrait you can contemplate, hates cubism. He is more impressed by the idea to transmit two-dimensional objects through three-dimensional objects by using his magnificent sculptures. And his new project is connected with this. Cicasso wants to make a coat for the haters of anticubism. To do this, he wants to create a sculpture depicting a well-known geometric primitive β convex polygon.
Cicasso prepared for this a few blanks, which are rods with integer lengths, and now he wants to bring them together. The i-th rod is a segment of length li.
The sculptor plans to make a convex polygon with a nonzero area, using all rods he has as its sides. Each rod should be used as a side to its full length. It is forbidden to cut, break or bend rods. However, two sides may form a straight angle <image>.
Cicasso knows that it is impossible to make a convex polygon with a nonzero area out of the rods with the lengths which he had chosen. Cicasso does not want to leave the unused rods, so the sculptor decides to make another rod-blank with an integer length so that his problem is solvable. Of course, he wants to make it as short as possible, because the materials are expensive, and it is improper deed to spend money for nothing.
Help sculptor!
Input
The first line contains an integer n (3 β€ n β€ 105) β a number of rod-blanks.
The second line contains n integers li (1 β€ li β€ 109) β lengths of rods, which Cicasso already has. It is guaranteed that it is impossible to make a polygon with n vertices and nonzero area using the rods Cicasso already has.
Output
Print the only integer z β the minimum length of the rod, so that after adding it it can be possible to construct convex polygon with (n + 1) vertices and nonzero area from all of the rods.
Examples
Input
3
1 2 1
Output
1
Input
5
20 4 3 2 1
Output
11
Note
In the first example triangle with sides {1 + 1 = 2, 2, 1} can be formed from a set of lengths {1, 1, 1, 2}.
In the second example you can make a triangle with lengths {20, 11, 4 + 3 + 2 + 1 = 10}.
Submitted Solution:
```
a=int(input())
s=[int(i) for i in input().split()]
s.sort()
s.reverse()
ans=s[0]-sum(s)+1
print(ans)
``` | instruction | 0 | 56,065 | 23 | 112,130 |
No | output | 1 | 56,065 | 23 | 112,131 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
<image>
As some of you know, cubism is a trend in art, where the problem of constructing volumetrical shape on a plane with a combination of three-dimensional geometric shapes comes to the fore.
A famous sculptor Cicasso, whose self-portrait you can contemplate, hates cubism. He is more impressed by the idea to transmit two-dimensional objects through three-dimensional objects by using his magnificent sculptures. And his new project is connected with this. Cicasso wants to make a coat for the haters of anticubism. To do this, he wants to create a sculpture depicting a well-known geometric primitive β convex polygon.
Cicasso prepared for this a few blanks, which are rods with integer lengths, and now he wants to bring them together. The i-th rod is a segment of length li.
The sculptor plans to make a convex polygon with a nonzero area, using all rods he has as its sides. Each rod should be used as a side to its full length. It is forbidden to cut, break or bend rods. However, two sides may form a straight angle <image>.
Cicasso knows that it is impossible to make a convex polygon with a nonzero area out of the rods with the lengths which he had chosen. Cicasso does not want to leave the unused rods, so the sculptor decides to make another rod-blank with an integer length so that his problem is solvable. Of course, he wants to make it as short as possible, because the materials are expensive, and it is improper deed to spend money for nothing.
Help sculptor!
Input
The first line contains an integer n (3 β€ n β€ 105) β a number of rod-blanks.
The second line contains n integers li (1 β€ li β€ 109) β lengths of rods, which Cicasso already has. It is guaranteed that it is impossible to make a polygon with n vertices and nonzero area using the rods Cicasso already has.
Output
Print the only integer z β the minimum length of the rod, so that after adding it it can be possible to construct convex polygon with (n + 1) vertices and nonzero area from all of the rods.
Examples
Input
3
1 2 1
Output
1
Input
5
20 4 3 2 1
Output
11
Note
In the first example triangle with sides {1 + 1 = 2, 2, 1} can be formed from a set of lengths {1, 1, 1, 2}.
In the second example you can make a triangle with lengths {20, 11, 4 + 3 + 2 + 1 = 10}.
Submitted Solution:
```
a = input()
b = input()
b = b.split()
c = []
for i in b:
c.append(int(i))
c.sort()
c.reverse()
d = int(b[0])
for i in range(1,int(a)):
d=d-int(c[i])
print (d+1)
``` | instruction | 0 | 56,066 | 23 | 112,132 |
No | output | 1 | 56,066 | 23 | 112,133 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
<image>
As some of you know, cubism is a trend in art, where the problem of constructing volumetrical shape on a plane with a combination of three-dimensional geometric shapes comes to the fore.
A famous sculptor Cicasso, whose self-portrait you can contemplate, hates cubism. He is more impressed by the idea to transmit two-dimensional objects through three-dimensional objects by using his magnificent sculptures. And his new project is connected with this. Cicasso wants to make a coat for the haters of anticubism. To do this, he wants to create a sculpture depicting a well-known geometric primitive β convex polygon.
Cicasso prepared for this a few blanks, which are rods with integer lengths, and now he wants to bring them together. The i-th rod is a segment of length li.
The sculptor plans to make a convex polygon with a nonzero area, using all rods he has as its sides. Each rod should be used as a side to its full length. It is forbidden to cut, break or bend rods. However, two sides may form a straight angle <image>.
Cicasso knows that it is impossible to make a convex polygon with a nonzero area out of the rods with the lengths which he had chosen. Cicasso does not want to leave the unused rods, so the sculptor decides to make another rod-blank with an integer length so that his problem is solvable. Of course, he wants to make it as short as possible, because the materials are expensive, and it is improper deed to spend money for nothing.
Help sculptor!
Input
The first line contains an integer n (3 β€ n β€ 105) β a number of rod-blanks.
The second line contains n integers li (1 β€ li β€ 109) β lengths of rods, which Cicasso already has. It is guaranteed that it is impossible to make a polygon with n vertices and nonzero area using the rods Cicasso already has.
Output
Print the only integer z β the minimum length of the rod, so that after adding it it can be possible to construct convex polygon with (n + 1) vertices and nonzero area from all of the rods.
Examples
Input
3
1 2 1
Output
1
Input
5
20 4 3 2 1
Output
11
Note
In the first example triangle with sides {1 + 1 = 2, 2, 1} can be formed from a set of lengths {1, 1, 1, 2}.
In the second example you can make a triangle with lengths {20, 11, 4 + 3 + 2 + 1 = 10}.
Submitted Solution:
```
n = int(input())
l = sorted([int(i)for i in input().split()])
SUM_SR =((max(l)+1)//2)*2 + 1
i = 0
while i < len(l)-1:
SUM_SR -= l[i]
i+=1
print(SUM_SR)
``` | instruction | 0 | 56,067 | 23 | 112,134 |
No | output | 1 | 56,067 | 23 | 112,135 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
<image>
As some of you know, cubism is a trend in art, where the problem of constructing volumetrical shape on a plane with a combination of three-dimensional geometric shapes comes to the fore.
A famous sculptor Cicasso, whose self-portrait you can contemplate, hates cubism. He is more impressed by the idea to transmit two-dimensional objects through three-dimensional objects by using his magnificent sculptures. And his new project is connected with this. Cicasso wants to make a coat for the haters of anticubism. To do this, he wants to create a sculpture depicting a well-known geometric primitive β convex polygon.
Cicasso prepared for this a few blanks, which are rods with integer lengths, and now he wants to bring them together. The i-th rod is a segment of length li.
The sculptor plans to make a convex polygon with a nonzero area, using all rods he has as its sides. Each rod should be used as a side to its full length. It is forbidden to cut, break or bend rods. However, two sides may form a straight angle <image>.
Cicasso knows that it is impossible to make a convex polygon with a nonzero area out of the rods with the lengths which he had chosen. Cicasso does not want to leave the unused rods, so the sculptor decides to make another rod-blank with an integer length so that his problem is solvable. Of course, he wants to make it as short as possible, because the materials are expensive, and it is improper deed to spend money for nothing.
Help sculptor!
Input
The first line contains an integer n (3 β€ n β€ 105) β a number of rod-blanks.
The second line contains n integers li (1 β€ li β€ 109) β lengths of rods, which Cicasso already has. It is guaranteed that it is impossible to make a polygon with n vertices and nonzero area using the rods Cicasso already has.
Output
Print the only integer z β the minimum length of the rod, so that after adding it it can be possible to construct convex polygon with (n + 1) vertices and nonzero area from all of the rods.
Examples
Input
3
1 2 1
Output
1
Input
5
20 4 3 2 1
Output
11
Note
In the first example triangle with sides {1 + 1 = 2, 2, 1} can be formed from a set of lengths {1, 1, 1, 2}.
In the second example you can make a triangle with lengths {20, 11, 4 + 3 + 2 + 1 = 10}.
Submitted Solution:
```
s = input()
s = input().split(" ")
k = []
for m in s:
k.append(int(m))
first = int(max(k))
second = 0
for x in k:
if x != first:
second += x
#print(first, second)
if first == second:
print(first - 1)
elif first > second:
print(second + 1)
elif first < second:
print(first + 1)
``` | instruction | 0 | 56,068 | 23 | 112,136 |
No | output | 1 | 56,068 | 23 | 112,137 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Owl Sonya gave a huge lake puzzle of size n Γ m to hedgehog Filya as a birthday present. Friends immediately started to assemble the puzzle, but some parts of it turned out to be empty β there was no picture on them. Parts with picture on it are denoted by 1, while empty parts are denoted by 0. Rows of the puzzle are numbered from top to bottom with integers from 1 to n, while columns are numbered from left to right with integers from 1 to m.
Animals decided to complete the picture and play with it, as it might be even more fun! Owl and hedgehog ask each other some queries. Each query is provided by four integers x1, y1, x2, y2 which define the rectangle, where (x1, y1) stands for the coordinates of the up left cell of the rectangle, while (x2, y2) stands for the coordinates of the bottom right cell. The answer to the query is the size of the maximum square consisting of picture parts only (only parts denoted by 1) and located fully inside the query rectangle.
Help Sonya and Filya answer t queries.
Input
The first line of the input contains two integers n and m (1 β€ n, m β€ 1000) β sizes of the puzzle.
Each of the following n lines contains m integers aij. Each of them is equal to 1 if the corresponding cell contains a picture and 0 if it's empty.
Next line contains an integer t (1 β€ t β€ 1 000 000) β the number of queries.
Then follow t lines with queries' descriptions. Each of them contains four integers x1, y1, x2, y2 (1 β€ x1 β€ x2 β€ n, 1 β€ y1 β€ y2 β€ m) β coordinates of the up left and bottom right cells of the query rectangle.
Output
Print t lines. The i-th of them should contain the maximum size of the square consisting of 1-s and lying fully inside the query rectangle.
Example
Input
3 4
1 1 0 1
0 1 1 0
0 1 1 0
5
1 1 2 3
2 1 3 2
3 2 3 4
1 1 3 4
1 2 3 4
Output
1
1
1
2
2
Submitted Solution:
```
import sys
I = lambda: int(input())
readline = lambda: sys.stdin.readline().strip('\n')
RM = readmap = lambda x=int: map(x,readline().split(' '))
import math
log2i = lambda x : int(math.log2(x))
n,m = RM()
l = [tuple(RM()) for i in range(n)]
dp = [[0]*(m+1) for i in range(n+1)]
for i in range(n): dp[i][0] = l[i][0]
for i in range(m): dp[0][i] = l[0][i]
for i in range(1,n):
for j in range(1,m):
dp[i][j] = [0,min(dp[i-1][j],dp[i-1][j-1],dp[i][j-1]) + 1][l[i][j]]
kn, km = log2i(n) + 1, log2i(m) + 1
st = [[ [ [0]*km for i1 in range(m)] for i2 in range(kn)]
for i3 in range(n)]
#zero case in second dimension / length
for ir in range(n):
for ic in range(m):#zero case in 1D breadth
st[ir][0][ic][0] = dp[ir][ic]
for kc in range(1,km):#1D sparse table for each row
for ic in range(m):
if ic + (1<<kc) > m: break
st[ir][0][ic][kc] = max(st[ir][0][ic][kc-1],
st[ir][0][ic+(1<<(kc-1))][kc-1])
for ic in range(m):
for kc in range(km):
for kr in range(1,kn):
for ir in range(n):
if ir + (1<<kr) > n: break
st[ir][kr][ic][kc] = max(st[ir][kr-1][ic][kc],
st[ir+(1<<(kr-1))][kr-1][ic][kc])
for _ in range(I()):
x1,y1,x2,y2 = RM()
x1-=1; x2-=1; y1-=1; y2-=1;
kx, ky = log2i(x2-x1+1), log2i(y2-y1+1)
#print(x1,x2,kx,y1,y2,ky)
max_R1 = max(st[x1][kx][y1][ky], st[x1][kx][y2+1-(1<<ky)][ky])
max_R2 = max(st[x2+1-(1<<kx)][kx][y1][ky],st[x2+1-(1<<kx)][kx][y2+1-(1<<ky)][ky])
print( min(max(max_R1,max_R2),x2-x1+1,y2-y1+1) )
#print(l,dp)
``` | instruction | 0 | 56,069 | 23 | 112,138 |
No | output | 1 | 56,069 | 23 | 112,139 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Owl Sonya gave a huge lake puzzle of size n Γ m to hedgehog Filya as a birthday present. Friends immediately started to assemble the puzzle, but some parts of it turned out to be empty β there was no picture on them. Parts with picture on it are denoted by 1, while empty parts are denoted by 0. Rows of the puzzle are numbered from top to bottom with integers from 1 to n, while columns are numbered from left to right with integers from 1 to m.
Animals decided to complete the picture and play with it, as it might be even more fun! Owl and hedgehog ask each other some queries. Each query is provided by four integers x1, y1, x2, y2 which define the rectangle, where (x1, y1) stands for the coordinates of the up left cell of the rectangle, while (x2, y2) stands for the coordinates of the bottom right cell. The answer to the query is the size of the maximum square consisting of picture parts only (only parts denoted by 1) and located fully inside the query rectangle.
Help Sonya and Filya answer t queries.
Input
The first line of the input contains two integers n and m (1 β€ n, m β€ 1000) β sizes of the puzzle.
Each of the following n lines contains m integers aij. Each of them is equal to 1 if the corresponding cell contains a picture and 0 if it's empty.
Next line contains an integer t (1 β€ t β€ 1 000 000) β the number of queries.
Then follow t lines with queries' descriptions. Each of them contains four integers x1, y1, x2, y2 (1 β€ x1 β€ x2 β€ n, 1 β€ y1 β€ y2 β€ m) β coordinates of the up left and bottom right cells of the query rectangle.
Output
Print t lines. The i-th of them should contain the maximum size of the square consisting of 1-s and lying fully inside the query rectangle.
Example
Input
3 4
1 1 0 1
0 1 1 0
0 1 1 0
5
1 1 2 3
2 1 3 2
3 2 3 4
1 1 3 4
1 2 3 4
Output
1
1
1
2
2
Submitted Solution:
```
import sys
I = lambda: int(input())
readline = lambda: sys.stdin.readline().strip('\n')
RM = readmap = lambda x=int: map(x,readline().split(' '))
import math
log2i = lambda x : int(math.log2(x))
n,m = RM()
l = [tuple(RM()) for i in range(n)]
dp = [[0]*(m+1) for i in range(n+1)]
for i in range(n): dp[i][0] = l[i][0]
for i in range(m): dp[0][i] = l[0][i]
for i in range(1,n):
for j in range(1,m):
dp[i][j] = [0,min(dp[i-1][j],dp[i-1][j-1],dp[i][j-1]) + 1][l[i][j]]
kn, km = log2i(n) + 1, log2i(m) + 1
st = [[ [ [0]*km for i1 in range(m)] for i2 in range(kn)]
for i3 in range(n)]
#zero case in second dimension / length
for ir in range(n):
for ic in range(m):#zero case in 1D breadth
st[ir][0][ic][0] = dp[ir][ic]
for kc in range(1,km):#1D sparse table for each row
for ic in range(m):
if ic + (1<<kc) > m: break
st[ir][0][ic][kc] = max(st[ir][0][ic][kc-1],
st[ir][0][ic+(1<<(kc-1))][kc-1])
for ic in range(m):
for kc in range(km):
for kr in range(1,kn):
for ir in range(n):
if ir + (1<<kr) > n: break
st[ir][kr][ic][kc] = max(st[ir][kr-1][ic][kc],
st[ir+(1<<(kr-1))][kr-1][ic][kc])
for _ in range(I()):
x1,y1,x2,y2 = RM()
x1-=1; x2-=1; y1-=1; y2-=1;
kx, ky = log2i(x2-x1+1), log2i(y2-y1+1)
print(x1,x2,kx,y1,y2,ky)
max_R1 = max(st[x1][kx][y1][ky], st[x1][kx][y2+1-(1<<ky)][ky])
max_R2 = max(st[x2+1-(1<<kx)][kx][y1][ky],st[x2+1-(1<<kx)][kx][y2+1-(1<<ky)][ky])
print( min(max(max_R1,max_R2),x2-x1+1,y2-y1+1) )
#print(l,dp)
``` | instruction | 0 | 56,070 | 23 | 112,140 |
No | output | 1 | 56,070 | 23 | 112,141 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.