message
stringlengths 2
39.6k
| message_type
stringclasses 2
values | message_id
int64 0
1
| conversation_id
int64 219
108k
| cluster
float64 11
11
| __index_level_0__
int64 438
217k
|
|---|---|---|---|---|---|
Provide tags and a correct Python 3 solution for this coding contest problem.
Vasya adores sport programming. He can't write programs but he loves to watch the contests' progress. Vasya even has a favorite coder and Vasya pays special attention to him.
One day Vasya decided to collect the results of all contests where his favorite coder participated and track the progress of his coolness. For each contest where this coder participated, he wrote out a single non-negative number — the number of points his favorite coder earned in the contest. Vasya wrote out the points for the contest in the order, in which the contests run (naturally, no two contests ran simultaneously).
Vasya considers a coder's performance in a contest amazing in two situations: he can break either his best or his worst performance record. First, it is amazing if during the contest the coder earns strictly more points that he earned on each past contest. Second, it is amazing if during the contest the coder earns strictly less points that he earned on each past contest. A coder's first contest isn't considered amazing. Now he wants to count the number of amazing performances the coder had throughout his whole history of participating in contests. But the list of earned points turned out long and Vasya can't code... That's why he asks you to help him.
Input
The first line contains the single integer n (1 ≤ n ≤ 1000) — the number of contests where the coder participated.
The next line contains n space-separated non-negative integer numbers — they are the points which the coder has earned. The points are given in the chronological order. All points do not exceed 10000.
Output
Print the single number — the number of amazing performances the coder has had during his whole history of participating in the contests.
Examples
Input
5
100 50 200 150 200
Output
2
Input
10
4664 6496 5814 7010 5762 5736 6944 4850 3698 7242
Output
4
Note
In the first sample the performances number 2 and 3 are amazing.
In the second sample the performances number 2, 4, 9 and 10 are amazing.
|
instruction
| 0
| 6,869
| 11
| 13,738
|
Tags: brute force
Correct Solution:
```
def main():
n = int(input())
scores = list(map(int , input().split()))
m, M, count = scores[0], scores[0], 0
for i in range(1, n):
if m < scores[i]:
m = scores[i]
count += 1
elif M > scores[i]:
M = scores[i]
count+= 1
print(count)
main()
```
|
output
| 1
| 6,869
| 11
| 13,739
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vasya adores sport programming. He can't write programs but he loves to watch the contests' progress. Vasya even has a favorite coder and Vasya pays special attention to him.
One day Vasya decided to collect the results of all contests where his favorite coder participated and track the progress of his coolness. For each contest where this coder participated, he wrote out a single non-negative number — the number of points his favorite coder earned in the contest. Vasya wrote out the points for the contest in the order, in which the contests run (naturally, no two contests ran simultaneously).
Vasya considers a coder's performance in a contest amazing in two situations: he can break either his best or his worst performance record. First, it is amazing if during the contest the coder earns strictly more points that he earned on each past contest. Second, it is amazing if during the contest the coder earns strictly less points that he earned on each past contest. A coder's first contest isn't considered amazing. Now he wants to count the number of amazing performances the coder had throughout his whole history of participating in contests. But the list of earned points turned out long and Vasya can't code... That's why he asks you to help him.
Input
The first line contains the single integer n (1 ≤ n ≤ 1000) — the number of contests where the coder participated.
The next line contains n space-separated non-negative integer numbers — they are the points which the coder has earned. The points are given in the chronological order. All points do not exceed 10000.
Output
Print the single number — the number of amazing performances the coder has had during his whole history of participating in the contests.
Examples
Input
5
100 50 200 150 200
Output
2
Input
10
4664 6496 5814 7010 5762 5736 6944 4850 3698 7242
Output
4
Note
In the first sample the performances number 2 and 3 are amazing.
In the second sample the performances number 2, 4, 9 and 10 are amazing.
Submitted Solution:
```
n=int(input())
l=list(map(int,input().split()))
mx=l[0]
mn=l[0]
c=0
for i in range(1,n):
if l[i]>mx:
c+=1
mx=l[i]
if l[i]<mn:
c+=1
mn=l[i]
print(c)
```
|
instruction
| 0
| 6,870
| 11
| 13,740
|
Yes
|
output
| 1
| 6,870
| 11
| 13,741
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vasya adores sport programming. He can't write programs but he loves to watch the contests' progress. Vasya even has a favorite coder and Vasya pays special attention to him.
One day Vasya decided to collect the results of all contests where his favorite coder participated and track the progress of his coolness. For each contest where this coder participated, he wrote out a single non-negative number — the number of points his favorite coder earned in the contest. Vasya wrote out the points for the contest in the order, in which the contests run (naturally, no two contests ran simultaneously).
Vasya considers a coder's performance in a contest amazing in two situations: he can break either his best or his worst performance record. First, it is amazing if during the contest the coder earns strictly more points that he earned on each past contest. Second, it is amazing if during the contest the coder earns strictly less points that he earned on each past contest. A coder's first contest isn't considered amazing. Now he wants to count the number of amazing performances the coder had throughout his whole history of participating in contests. But the list of earned points turned out long and Vasya can't code... That's why he asks you to help him.
Input
The first line contains the single integer n (1 ≤ n ≤ 1000) — the number of contests where the coder participated.
The next line contains n space-separated non-negative integer numbers — they are the points which the coder has earned. The points are given in the chronological order. All points do not exceed 10000.
Output
Print the single number — the number of amazing performances the coder has had during his whole history of participating in the contests.
Examples
Input
5
100 50 200 150 200
Output
2
Input
10
4664 6496 5814 7010 5762 5736 6944 4850 3698 7242
Output
4
Note
In the first sample the performances number 2 and 3 are amazing.
In the second sample the performances number 2, 4, 9 and 10 are amazing.
Submitted Solution:
```
n = int(input())
contest_scores = list(map(int, input().split()))
min_score = max_score = contest_scores[0]
result = 0
for k in range(1, len(contest_scores)):
tmp_score = contest_scores[k]
if tmp_score > max_score:
result += 1
if tmp_score < min_score:
result += 1
max_score = max(tmp_score, max_score)
min_score = min(tmp_score, min_score)
print(result)
```
|
instruction
| 0
| 6,871
| 11
| 13,742
|
Yes
|
output
| 1
| 6,871
| 11
| 13,743
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vasya adores sport programming. He can't write programs but he loves to watch the contests' progress. Vasya even has a favorite coder and Vasya pays special attention to him.
One day Vasya decided to collect the results of all contests where his favorite coder participated and track the progress of his coolness. For each contest where this coder participated, he wrote out a single non-negative number — the number of points his favorite coder earned in the contest. Vasya wrote out the points for the contest in the order, in which the contests run (naturally, no two contests ran simultaneously).
Vasya considers a coder's performance in a contest amazing in two situations: he can break either his best or his worst performance record. First, it is amazing if during the contest the coder earns strictly more points that he earned on each past contest. Second, it is amazing if during the contest the coder earns strictly less points that he earned on each past contest. A coder's first contest isn't considered amazing. Now he wants to count the number of amazing performances the coder had throughout his whole history of participating in contests. But the list of earned points turned out long and Vasya can't code... That's why he asks you to help him.
Input
The first line contains the single integer n (1 ≤ n ≤ 1000) — the number of contests where the coder participated.
The next line contains n space-separated non-negative integer numbers — they are the points which the coder has earned. The points are given in the chronological order. All points do not exceed 10000.
Output
Print the single number — the number of amazing performances the coder has had during his whole history of participating in the contests.
Examples
Input
5
100 50 200 150 200
Output
2
Input
10
4664 6496 5814 7010 5762 5736 6944 4850 3698 7242
Output
4
Note
In the first sample the performances number 2 and 3 are amazing.
In the second sample the performances number 2, 4, 9 and 10 are amazing.
Submitted Solution:
```
n = int(input())
t = [int(x) for x in input().split()]
k = 0
l = t[0]
m = t[0]
for i in range(1,n):
if t[i] > l:
k += 1
l = t[i]
elif t[i] < m:
k += 1
m = t[i]
print(k)
```
|
instruction
| 0
| 6,872
| 11
| 13,744
|
Yes
|
output
| 1
| 6,872
| 11
| 13,745
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vasya adores sport programming. He can't write programs but he loves to watch the contests' progress. Vasya even has a favorite coder and Vasya pays special attention to him.
One day Vasya decided to collect the results of all contests where his favorite coder participated and track the progress of his coolness. For each contest where this coder participated, he wrote out a single non-negative number — the number of points his favorite coder earned in the contest. Vasya wrote out the points for the contest in the order, in which the contests run (naturally, no two contests ran simultaneously).
Vasya considers a coder's performance in a contest amazing in two situations: he can break either his best or his worst performance record. First, it is amazing if during the contest the coder earns strictly more points that he earned on each past contest. Second, it is amazing if during the contest the coder earns strictly less points that he earned on each past contest. A coder's first contest isn't considered amazing. Now he wants to count the number of amazing performances the coder had throughout his whole history of participating in contests. But the list of earned points turned out long and Vasya can't code... That's why he asks you to help him.
Input
The first line contains the single integer n (1 ≤ n ≤ 1000) — the number of contests where the coder participated.
The next line contains n space-separated non-negative integer numbers — they are the points which the coder has earned. The points are given in the chronological order. All points do not exceed 10000.
Output
Print the single number — the number of amazing performances the coder has had during his whole history of participating in the contests.
Examples
Input
5
100 50 200 150 200
Output
2
Input
10
4664 6496 5814 7010 5762 5736 6944 4850 3698 7242
Output
4
Note
In the first sample the performances number 2 and 3 are amazing.
In the second sample the performances number 2, 4, 9 and 10 are amazing.
Submitted Solution:
```
n = int(input())
max = -1
min = 1e9
ans = 0
for i in map(int, input().split(' ')):
if i > max:
max = i
ans += 1
if i < min:
min = i
ans += 1
print(ans - 2)
```
|
instruction
| 0
| 6,873
| 11
| 13,746
|
Yes
|
output
| 1
| 6,873
| 11
| 13,747
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vasya adores sport programming. He can't write programs but he loves to watch the contests' progress. Vasya even has a favorite coder and Vasya pays special attention to him.
One day Vasya decided to collect the results of all contests where his favorite coder participated and track the progress of his coolness. For each contest where this coder participated, he wrote out a single non-negative number — the number of points his favorite coder earned in the contest. Vasya wrote out the points for the contest in the order, in which the contests run (naturally, no two contests ran simultaneously).
Vasya considers a coder's performance in a contest amazing in two situations: he can break either his best or his worst performance record. First, it is amazing if during the contest the coder earns strictly more points that he earned on each past contest. Second, it is amazing if during the contest the coder earns strictly less points that he earned on each past contest. A coder's first contest isn't considered amazing. Now he wants to count the number of amazing performances the coder had throughout his whole history of participating in contests. But the list of earned points turned out long and Vasya can't code... That's why he asks you to help him.
Input
The first line contains the single integer n (1 ≤ n ≤ 1000) — the number of contests where the coder participated.
The next line contains n space-separated non-negative integer numbers — they are the points which the coder has earned. The points are given in the chronological order. All points do not exceed 10000.
Output
Print the single number — the number of amazing performances the coder has had during his whole history of participating in the contests.
Examples
Input
5
100 50 200 150 200
Output
2
Input
10
4664 6496 5814 7010 5762 5736 6944 4850 3698 7242
Output
4
Note
In the first sample the performances number 2 and 3 are amazing.
In the second sample the performances number 2, 4, 9 and 10 are amazing.
Submitted Solution:
```
lines = ''
for i in range(2):
lines+=input()+"\n"
lines = lines.split('\n')
nums = map(int, lines[1].split(" "))
u, q = 0, 0
x = []
for n in nums:
if n > q:
u += 1
q = n
print(u - 1 or 1 if int(lines[0]) > 0 else 0)
```
|
instruction
| 0
| 6,874
| 11
| 13,748
|
No
|
output
| 1
| 6,874
| 11
| 13,749
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vasya adores sport programming. He can't write programs but he loves to watch the contests' progress. Vasya even has a favorite coder and Vasya pays special attention to him.
One day Vasya decided to collect the results of all contests where his favorite coder participated and track the progress of his coolness. For each contest where this coder participated, he wrote out a single non-negative number — the number of points his favorite coder earned in the contest. Vasya wrote out the points for the contest in the order, in which the contests run (naturally, no two contests ran simultaneously).
Vasya considers a coder's performance in a contest amazing in two situations: he can break either his best or his worst performance record. First, it is amazing if during the contest the coder earns strictly more points that he earned on each past contest. Second, it is amazing if during the contest the coder earns strictly less points that he earned on each past contest. A coder's first contest isn't considered amazing. Now he wants to count the number of amazing performances the coder had throughout his whole history of participating in contests. But the list of earned points turned out long and Vasya can't code... That's why he asks you to help him.
Input
The first line contains the single integer n (1 ≤ n ≤ 1000) — the number of contests where the coder participated.
The next line contains n space-separated non-negative integer numbers — they are the points which the coder has earned. The points are given in the chronological order. All points do not exceed 10000.
Output
Print the single number — the number of amazing performances the coder has had during his whole history of participating in the contests.
Examples
Input
5
100 50 200 150 200
Output
2
Input
10
4664 6496 5814 7010 5762 5736 6944 4850 3698 7242
Output
4
Note
In the first sample the performances number 2 and 3 are amazing.
In the second sample the performances number 2, 4, 9 and 10 are amazing.
Submitted Solution:
```
def funct(n,l):
cnt=0
for i in range(1,n):
if(l[i]>l[i-1]):
cnt+=1
return cnt
n=int(input())
l=list(map(int,input().split()))
print(funct(n,l))
```
|
instruction
| 0
| 6,875
| 11
| 13,750
|
No
|
output
| 1
| 6,875
| 11
| 13,751
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vasya adores sport programming. He can't write programs but he loves to watch the contests' progress. Vasya even has a favorite coder and Vasya pays special attention to him.
One day Vasya decided to collect the results of all contests where his favorite coder participated and track the progress of his coolness. For each contest where this coder participated, he wrote out a single non-negative number — the number of points his favorite coder earned in the contest. Vasya wrote out the points for the contest in the order, in which the contests run (naturally, no two contests ran simultaneously).
Vasya considers a coder's performance in a contest amazing in two situations: he can break either his best or his worst performance record. First, it is amazing if during the contest the coder earns strictly more points that he earned on each past contest. Second, it is amazing if during the contest the coder earns strictly less points that he earned on each past contest. A coder's first contest isn't considered amazing. Now he wants to count the number of amazing performances the coder had throughout his whole history of participating in contests. But the list of earned points turned out long and Vasya can't code... That's why he asks you to help him.
Input
The first line contains the single integer n (1 ≤ n ≤ 1000) — the number of contests where the coder participated.
The next line contains n space-separated non-negative integer numbers — they are the points which the coder has earned. The points are given in the chronological order. All points do not exceed 10000.
Output
Print the single number — the number of amazing performances the coder has had during his whole history of participating in the contests.
Examples
Input
5
100 50 200 150 200
Output
2
Input
10
4664 6496 5814 7010 5762 5736 6944 4850 3698 7242
Output
4
Note
In the first sample the performances number 2 and 3 are amazing.
In the second sample the performances number 2, 4, 9 and 10 are amazing.
Submitted Solution:
```
a=int(input())
nume=[]
nume=input().split(" ")
soma=0
if a<10:
for i in nume:
soma+=int(i)
media=soma/a
cont=0
for i in nume:
if media<int(i):
cont+=1
print(cont-1)
else:
for i in nume:
soma+=int(i)
media=soma/a
cont=0
for i in nume:
if media<int(i):
cont+=1
print(cont)
```
|
instruction
| 0
| 6,876
| 11
| 13,752
|
No
|
output
| 1
| 6,876
| 11
| 13,753
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vasya adores sport programming. He can't write programs but he loves to watch the contests' progress. Vasya even has a favorite coder and Vasya pays special attention to him.
One day Vasya decided to collect the results of all contests where his favorite coder participated and track the progress of his coolness. For each contest where this coder participated, he wrote out a single non-negative number — the number of points his favorite coder earned in the contest. Vasya wrote out the points for the contest in the order, in which the contests run (naturally, no two contests ran simultaneously).
Vasya considers a coder's performance in a contest amazing in two situations: he can break either his best or his worst performance record. First, it is amazing if during the contest the coder earns strictly more points that he earned on each past contest. Second, it is amazing if during the contest the coder earns strictly less points that he earned on each past contest. A coder's first contest isn't considered amazing. Now he wants to count the number of amazing performances the coder had throughout his whole history of participating in contests. But the list of earned points turned out long and Vasya can't code... That's why he asks you to help him.
Input
The first line contains the single integer n (1 ≤ n ≤ 1000) — the number of contests where the coder participated.
The next line contains n space-separated non-negative integer numbers — they are the points which the coder has earned. The points are given in the chronological order. All points do not exceed 10000.
Output
Print the single number — the number of amazing performances the coder has had during his whole history of participating in the contests.
Examples
Input
5
100 50 200 150 200
Output
2
Input
10
4664 6496 5814 7010 5762 5736 6944 4850 3698 7242
Output
4
Note
In the first sample the performances number 2 and 3 are amazing.
In the second sample the performances number 2, 4, 9 and 10 are amazing.
Submitted Solution:
```
k=int(input())
ls=list(map(int,input().split()))
count=0
for i in range(1,k):
if ls[i]>ls[i-1]:
count+=1
print(count)
```
|
instruction
| 0
| 6,877
| 11
| 13,754
|
No
|
output
| 1
| 6,877
| 11
| 13,755
|
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a problemset consisting of n problems. The difficulty of the i-th problem is a_i. It is guaranteed that all difficulties are distinct and are given in the increasing order.
You have to assemble the contest which consists of some problems of the given problemset. In other words, the contest you have to assemble should be a subset of problems (not necessary consecutive) of the given problemset. There is only one condition that should be satisfied: for each problem but the hardest one (the problem with the maximum difficulty) there should be a problem with the difficulty greater than the difficulty of this problem but not greater than twice the difficulty of this problem. In other words, let a_{i_1}, a_{i_2}, ..., a_{i_p} be the difficulties of the selected problems in increasing order. Then for each j from 1 to p-1 a_{i_{j + 1}} ≤ a_{i_j} ⋅ 2 should hold. It means that the contest consisting of only one problem is always valid.
Among all contests satisfying the condition above you have to assemble one with the maximum number of problems. Your task is to find this number of problems.
Input
The first line of the input contains one integer n (1 ≤ n ≤ 2 ⋅ 10^5) — the number of problems in the problemset.
The second line of the input contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9) — difficulties of the problems. It is guaranteed that difficulties of the problems are distinct and are given in the increasing order.
Output
Print a single integer — maximum number of problems in the contest satisfying the condition in the problem statement.
Examples
Input
10
1 2 5 6 7 10 21 23 24 49
Output
4
Input
5
2 10 50 110 250
Output
1
Input
6
4 7 12 100 150 199
Output
3
Note
Description of the first example: there are 10 valid contests consisting of 1 problem, 10 valid contests consisting of 2 problems ([1, 2], [5, 6], [5, 7], [5, 10], [6, 7], [6, 10], [7, 10], [21, 23], [21, 24], [23, 24]), 5 valid contests consisting of 3 problems ([5, 6, 7], [5, 6, 10], [5, 7, 10], [6, 7, 10], [21, 23, 24]) and a single valid contest consisting of 4 problems ([5, 6, 7, 10]).
In the second example all the valid contests consist of 1 problem.
In the third example are two contests consisting of 3 problems: [4, 7, 12] and [100, 150, 199].
|
instruction
| 0
| 7,549
| 11
| 15,098
|
Tags: dp, greedy, math
Correct Solution:
```
import sys
def input(): return sys.stdin.readline()[:-1]
# def input(): return sys.stdin.buffer.readline()[:-1]
n = int(input())
a = [int(x) for x in input().split()]
ans = 1
cur = 1
for i in range(1, n):
if a[i - 1] * 2 >= a[i]:
cur += 1
else:
cur = 1
ans = max(ans, cur)
print(ans)
```
|
output
| 1
| 7,549
| 11
| 15,099
|
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a problemset consisting of n problems. The difficulty of the i-th problem is a_i. It is guaranteed that all difficulties are distinct and are given in the increasing order.
You have to assemble the contest which consists of some problems of the given problemset. In other words, the contest you have to assemble should be a subset of problems (not necessary consecutive) of the given problemset. There is only one condition that should be satisfied: for each problem but the hardest one (the problem with the maximum difficulty) there should be a problem with the difficulty greater than the difficulty of this problem but not greater than twice the difficulty of this problem. In other words, let a_{i_1}, a_{i_2}, ..., a_{i_p} be the difficulties of the selected problems in increasing order. Then for each j from 1 to p-1 a_{i_{j + 1}} ≤ a_{i_j} ⋅ 2 should hold. It means that the contest consisting of only one problem is always valid.
Among all contests satisfying the condition above you have to assemble one with the maximum number of problems. Your task is to find this number of problems.
Input
The first line of the input contains one integer n (1 ≤ n ≤ 2 ⋅ 10^5) — the number of problems in the problemset.
The second line of the input contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9) — difficulties of the problems. It is guaranteed that difficulties of the problems are distinct and are given in the increasing order.
Output
Print a single integer — maximum number of problems in the contest satisfying the condition in the problem statement.
Examples
Input
10
1 2 5 6 7 10 21 23 24 49
Output
4
Input
5
2 10 50 110 250
Output
1
Input
6
4 7 12 100 150 199
Output
3
Note
Description of the first example: there are 10 valid contests consisting of 1 problem, 10 valid contests consisting of 2 problems ([1, 2], [5, 6], [5, 7], [5, 10], [6, 7], [6, 10], [7, 10], [21, 23], [21, 24], [23, 24]), 5 valid contests consisting of 3 problems ([5, 6, 7], [5, 6, 10], [5, 7, 10], [6, 7, 10], [21, 23, 24]) and a single valid contest consisting of 4 problems ([5, 6, 7, 10]).
In the second example all the valid contests consist of 1 problem.
In the third example are two contests consisting of 3 problems: [4, 7, 12] and [100, 150, 199].
|
instruction
| 0
| 7,550
| 11
| 15,100
|
Tags: dp, greedy, math
Correct Solution:
```
n=int(input())
a=list(map(int,input().split()))
p=0
m=1
for i in a:
if i>p*2:
c=1
else:
c+=1
m=max(c,m)
p=i
m=max(m,c)
print(m)
```
|
output
| 1
| 7,550
| 11
| 15,101
|
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a problemset consisting of n problems. The difficulty of the i-th problem is a_i. It is guaranteed that all difficulties are distinct and are given in the increasing order.
You have to assemble the contest which consists of some problems of the given problemset. In other words, the contest you have to assemble should be a subset of problems (not necessary consecutive) of the given problemset. There is only one condition that should be satisfied: for each problem but the hardest one (the problem with the maximum difficulty) there should be a problem with the difficulty greater than the difficulty of this problem but not greater than twice the difficulty of this problem. In other words, let a_{i_1}, a_{i_2}, ..., a_{i_p} be the difficulties of the selected problems in increasing order. Then for each j from 1 to p-1 a_{i_{j + 1}} ≤ a_{i_j} ⋅ 2 should hold. It means that the contest consisting of only one problem is always valid.
Among all contests satisfying the condition above you have to assemble one with the maximum number of problems. Your task is to find this number of problems.
Input
The first line of the input contains one integer n (1 ≤ n ≤ 2 ⋅ 10^5) — the number of problems in the problemset.
The second line of the input contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9) — difficulties of the problems. It is guaranteed that difficulties of the problems are distinct and are given in the increasing order.
Output
Print a single integer — maximum number of problems in the contest satisfying the condition in the problem statement.
Examples
Input
10
1 2 5 6 7 10 21 23 24 49
Output
4
Input
5
2 10 50 110 250
Output
1
Input
6
4 7 12 100 150 199
Output
3
Note
Description of the first example: there are 10 valid contests consisting of 1 problem, 10 valid contests consisting of 2 problems ([1, 2], [5, 6], [5, 7], [5, 10], [6, 7], [6, 10], [7, 10], [21, 23], [21, 24], [23, 24]), 5 valid contests consisting of 3 problems ([5, 6, 7], [5, 6, 10], [5, 7, 10], [6, 7, 10], [21, 23, 24]) and a single valid contest consisting of 4 problems ([5, 6, 7, 10]).
In the second example all the valid contests consist of 1 problem.
In the third example are two contests consisting of 3 problems: [4, 7, 12] and [100, 150, 199].
|
instruction
| 0
| 7,551
| 11
| 15,102
|
Tags: dp, greedy, math
Correct Solution:
```
#iamanshup
n = int(input())
l = list(map(int, input().split()))
ans = 1
m = 1
for i in range(n-1):
if 2*l[i]>=l[i+1]:
m+=1
else:
m = 1
ans = max(ans, m)
print(ans)
```
|
output
| 1
| 7,551
| 11
| 15,103
|
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a problemset consisting of n problems. The difficulty of the i-th problem is a_i. It is guaranteed that all difficulties are distinct and are given in the increasing order.
You have to assemble the contest which consists of some problems of the given problemset. In other words, the contest you have to assemble should be a subset of problems (not necessary consecutive) of the given problemset. There is only one condition that should be satisfied: for each problem but the hardest one (the problem with the maximum difficulty) there should be a problem with the difficulty greater than the difficulty of this problem but not greater than twice the difficulty of this problem. In other words, let a_{i_1}, a_{i_2}, ..., a_{i_p} be the difficulties of the selected problems in increasing order. Then for each j from 1 to p-1 a_{i_{j + 1}} ≤ a_{i_j} ⋅ 2 should hold. It means that the contest consisting of only one problem is always valid.
Among all contests satisfying the condition above you have to assemble one with the maximum number of problems. Your task is to find this number of problems.
Input
The first line of the input contains one integer n (1 ≤ n ≤ 2 ⋅ 10^5) — the number of problems in the problemset.
The second line of the input contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9) — difficulties of the problems. It is guaranteed that difficulties of the problems are distinct and are given in the increasing order.
Output
Print a single integer — maximum number of problems in the contest satisfying the condition in the problem statement.
Examples
Input
10
1 2 5 6 7 10 21 23 24 49
Output
4
Input
5
2 10 50 110 250
Output
1
Input
6
4 7 12 100 150 199
Output
3
Note
Description of the first example: there are 10 valid contests consisting of 1 problem, 10 valid contests consisting of 2 problems ([1, 2], [5, 6], [5, 7], [5, 10], [6, 7], [6, 10], [7, 10], [21, 23], [21, 24], [23, 24]), 5 valid contests consisting of 3 problems ([5, 6, 7], [5, 6, 10], [5, 7, 10], [6, 7, 10], [21, 23, 24]) and a single valid contest consisting of 4 problems ([5, 6, 7, 10]).
In the second example all the valid contests consist of 1 problem.
In the third example are two contests consisting of 3 problems: [4, 7, 12] and [100, 150, 199].
|
instruction
| 0
| 7,552
| 11
| 15,104
|
Tags: dp, greedy, math
Correct Solution:
```
from collections import deque
from sys import stdin
lines = deque(line.strip() for line in stdin.readlines())
def nextline():
return lines.popleft()
def types(cast, sep=None):
return tuple(cast(x) for x in strs(sep=sep))
def ints(sep=None):
return types(int, sep=sep)
def strs(sep=None):
return tuple(nextline()) if sep == '' else tuple(nextline().split(sep=sep))
def main():
# lines will now contain all of the input's lines in a list
n = int(nextline())
nums = ints()
largest_group = 0
last_num = nums[0]
curr_group = 1
for i in range(1, n):
if nums[i] > 2 * last_num:
largest_group = max(largest_group, curr_group)
curr_group = 1
else:
curr_group += 1
last_num = nums[i]
print(max(largest_group, curr_group))
if __name__ == '__main__':
main()
```
|
output
| 1
| 7,552
| 11
| 15,105
|
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a problemset consisting of n problems. The difficulty of the i-th problem is a_i. It is guaranteed that all difficulties are distinct and are given in the increasing order.
You have to assemble the contest which consists of some problems of the given problemset. In other words, the contest you have to assemble should be a subset of problems (not necessary consecutive) of the given problemset. There is only one condition that should be satisfied: for each problem but the hardest one (the problem with the maximum difficulty) there should be a problem with the difficulty greater than the difficulty of this problem but not greater than twice the difficulty of this problem. In other words, let a_{i_1}, a_{i_2}, ..., a_{i_p} be the difficulties of the selected problems in increasing order. Then for each j from 1 to p-1 a_{i_{j + 1}} ≤ a_{i_j} ⋅ 2 should hold. It means that the contest consisting of only one problem is always valid.
Among all contests satisfying the condition above you have to assemble one with the maximum number of problems. Your task is to find this number of problems.
Input
The first line of the input contains one integer n (1 ≤ n ≤ 2 ⋅ 10^5) — the number of problems in the problemset.
The second line of the input contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9) — difficulties of the problems. It is guaranteed that difficulties of the problems are distinct and are given in the increasing order.
Output
Print a single integer — maximum number of problems in the contest satisfying the condition in the problem statement.
Examples
Input
10
1 2 5 6 7 10 21 23 24 49
Output
4
Input
5
2 10 50 110 250
Output
1
Input
6
4 7 12 100 150 199
Output
3
Note
Description of the first example: there are 10 valid contests consisting of 1 problem, 10 valid contests consisting of 2 problems ([1, 2], [5, 6], [5, 7], [5, 10], [6, 7], [6, 10], [7, 10], [21, 23], [21, 24], [23, 24]), 5 valid contests consisting of 3 problems ([5, 6, 7], [5, 6, 10], [5, 7, 10], [6, 7, 10], [21, 23, 24]) and a single valid contest consisting of 4 problems ([5, 6, 7, 10]).
In the second example all the valid contests consist of 1 problem.
In the third example are two contests consisting of 3 problems: [4, 7, 12] and [100, 150, 199].
|
instruction
| 0
| 7,553
| 11
| 15,106
|
Tags: dp, greedy, math
Correct Solution:
```
n= int(input())
l=list(map(int,input().split()))
if(n==1):
print(1)
else:
t=[]
ans=1
for i in range(n-1):
if(l[i]*2>=l[i+1]):
ans+=1
else:
t.append(ans)
if(i==n-2):
t.append(1)
ans=1
if(i==n-2 and l[i]*2>=l[i+1]):
t.append(ans)
print(max(t))
```
|
output
| 1
| 7,553
| 11
| 15,107
|
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a problemset consisting of n problems. The difficulty of the i-th problem is a_i. It is guaranteed that all difficulties are distinct and are given in the increasing order.
You have to assemble the contest which consists of some problems of the given problemset. In other words, the contest you have to assemble should be a subset of problems (not necessary consecutive) of the given problemset. There is only one condition that should be satisfied: for each problem but the hardest one (the problem with the maximum difficulty) there should be a problem with the difficulty greater than the difficulty of this problem but not greater than twice the difficulty of this problem. In other words, let a_{i_1}, a_{i_2}, ..., a_{i_p} be the difficulties of the selected problems in increasing order. Then for each j from 1 to p-1 a_{i_{j + 1}} ≤ a_{i_j} ⋅ 2 should hold. It means that the contest consisting of only one problem is always valid.
Among all contests satisfying the condition above you have to assemble one with the maximum number of problems. Your task is to find this number of problems.
Input
The first line of the input contains one integer n (1 ≤ n ≤ 2 ⋅ 10^5) — the number of problems in the problemset.
The second line of the input contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9) — difficulties of the problems. It is guaranteed that difficulties of the problems are distinct and are given in the increasing order.
Output
Print a single integer — maximum number of problems in the contest satisfying the condition in the problem statement.
Examples
Input
10
1 2 5 6 7 10 21 23 24 49
Output
4
Input
5
2 10 50 110 250
Output
1
Input
6
4 7 12 100 150 199
Output
3
Note
Description of the first example: there are 10 valid contests consisting of 1 problem, 10 valid contests consisting of 2 problems ([1, 2], [5, 6], [5, 7], [5, 10], [6, 7], [6, 10], [7, 10], [21, 23], [21, 24], [23, 24]), 5 valid contests consisting of 3 problems ([5, 6, 7], [5, 6, 10], [5, 7, 10], [6, 7, 10], [21, 23, 24]) and a single valid contest consisting of 4 problems ([5, 6, 7, 10]).
In the second example all the valid contests consist of 1 problem.
In the third example are two contests consisting of 3 problems: [4, 7, 12] and [100, 150, 199].
|
instruction
| 0
| 7,554
| 11
| 15,108
|
Tags: dp, greedy, math
Correct Solution:
```
n = int(input())
a = list(map(int, input().split()))
x = [0]
for i in range(1, n):
if a[i - 1] * 2 < a[i]:
x.append(i)
x.append(n)
ans = 0
m = len(x)
for i in range(1, m):
ans = max(ans, x[i] - x[i - 1])
print(ans)
```
|
output
| 1
| 7,554
| 11
| 15,109
|
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a problemset consisting of n problems. The difficulty of the i-th problem is a_i. It is guaranteed that all difficulties are distinct and are given in the increasing order.
You have to assemble the contest which consists of some problems of the given problemset. In other words, the contest you have to assemble should be a subset of problems (not necessary consecutive) of the given problemset. There is only one condition that should be satisfied: for each problem but the hardest one (the problem with the maximum difficulty) there should be a problem with the difficulty greater than the difficulty of this problem but not greater than twice the difficulty of this problem. In other words, let a_{i_1}, a_{i_2}, ..., a_{i_p} be the difficulties of the selected problems in increasing order. Then for each j from 1 to p-1 a_{i_{j + 1}} ≤ a_{i_j} ⋅ 2 should hold. It means that the contest consisting of only one problem is always valid.
Among all contests satisfying the condition above you have to assemble one with the maximum number of problems. Your task is to find this number of problems.
Input
The first line of the input contains one integer n (1 ≤ n ≤ 2 ⋅ 10^5) — the number of problems in the problemset.
The second line of the input contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9) — difficulties of the problems. It is guaranteed that difficulties of the problems are distinct and are given in the increasing order.
Output
Print a single integer — maximum number of problems in the contest satisfying the condition in the problem statement.
Examples
Input
10
1 2 5 6 7 10 21 23 24 49
Output
4
Input
5
2 10 50 110 250
Output
1
Input
6
4 7 12 100 150 199
Output
3
Note
Description of the first example: there are 10 valid contests consisting of 1 problem, 10 valid contests consisting of 2 problems ([1, 2], [5, 6], [5, 7], [5, 10], [6, 7], [6, 10], [7, 10], [21, 23], [21, 24], [23, 24]), 5 valid contests consisting of 3 problems ([5, 6, 7], [5, 6, 10], [5, 7, 10], [6, 7, 10], [21, 23, 24]) and a single valid contest consisting of 4 problems ([5, 6, 7, 10]).
In the second example all the valid contests consist of 1 problem.
In the third example are two contests consisting of 3 problems: [4, 7, 12] and [100, 150, 199].
|
instruction
| 0
| 7,555
| 11
| 15,110
|
Tags: dp, greedy, math
Correct Solution:
```
n = int(input())
a = list(map(int, input().split()))
a.append(a[n - 1] * 3)
max_ans = 1
ans = 1
for i in range(n):
if a[i] * 2 < a[i + 1]:
if ans > max_ans:
max_ans = ans
ans = 1
else:
ans += 1
print(max_ans)
```
|
output
| 1
| 7,555
| 11
| 15,111
|
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a problemset consisting of n problems. The difficulty of the i-th problem is a_i. It is guaranteed that all difficulties are distinct and are given in the increasing order.
You have to assemble the contest which consists of some problems of the given problemset. In other words, the contest you have to assemble should be a subset of problems (not necessary consecutive) of the given problemset. There is only one condition that should be satisfied: for each problem but the hardest one (the problem with the maximum difficulty) there should be a problem with the difficulty greater than the difficulty of this problem but not greater than twice the difficulty of this problem. In other words, let a_{i_1}, a_{i_2}, ..., a_{i_p} be the difficulties of the selected problems in increasing order. Then for each j from 1 to p-1 a_{i_{j + 1}} ≤ a_{i_j} ⋅ 2 should hold. It means that the contest consisting of only one problem is always valid.
Among all contests satisfying the condition above you have to assemble one with the maximum number of problems. Your task is to find this number of problems.
Input
The first line of the input contains one integer n (1 ≤ n ≤ 2 ⋅ 10^5) — the number of problems in the problemset.
The second line of the input contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9) — difficulties of the problems. It is guaranteed that difficulties of the problems are distinct and are given in the increasing order.
Output
Print a single integer — maximum number of problems in the contest satisfying the condition in the problem statement.
Examples
Input
10
1 2 5 6 7 10 21 23 24 49
Output
4
Input
5
2 10 50 110 250
Output
1
Input
6
4 7 12 100 150 199
Output
3
Note
Description of the first example: there are 10 valid contests consisting of 1 problem, 10 valid contests consisting of 2 problems ([1, 2], [5, 6], [5, 7], [5, 10], [6, 7], [6, 10], [7, 10], [21, 23], [21, 24], [23, 24]), 5 valid contests consisting of 3 problems ([5, 6, 7], [5, 6, 10], [5, 7, 10], [6, 7, 10], [21, 23, 24]) and a single valid contest consisting of 4 problems ([5, 6, 7, 10]).
In the second example all the valid contests consist of 1 problem.
In the third example are two contests consisting of 3 problems: [4, 7, 12] and [100, 150, 199].
|
instruction
| 0
| 7,556
| 11
| 15,112
|
Tags: dp, greedy, math
Correct Solution:
```
amount = int(input())
diffs = [int(i) for i in input().split()]
ret = 1
m = 1
for i in range(1, amount):
if diffs[i] <= diffs[i - 1] * 2:
m += 1
ret = max(ret, m)
else:
m = 1
print(ret)
```
|
output
| 1
| 7,556
| 11
| 15,113
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a problemset consisting of n problems. The difficulty of the i-th problem is a_i. It is guaranteed that all difficulties are distinct and are given in the increasing order.
You have to assemble the contest which consists of some problems of the given problemset. In other words, the contest you have to assemble should be a subset of problems (not necessary consecutive) of the given problemset. There is only one condition that should be satisfied: for each problem but the hardest one (the problem with the maximum difficulty) there should be a problem with the difficulty greater than the difficulty of this problem but not greater than twice the difficulty of this problem. In other words, let a_{i_1}, a_{i_2}, ..., a_{i_p} be the difficulties of the selected problems in increasing order. Then for each j from 1 to p-1 a_{i_{j + 1}} ≤ a_{i_j} ⋅ 2 should hold. It means that the contest consisting of only one problem is always valid.
Among all contests satisfying the condition above you have to assemble one with the maximum number of problems. Your task is to find this number of problems.
Input
The first line of the input contains one integer n (1 ≤ n ≤ 2 ⋅ 10^5) — the number of problems in the problemset.
The second line of the input contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9) — difficulties of the problems. It is guaranteed that difficulties of the problems are distinct and are given in the increasing order.
Output
Print a single integer — maximum number of problems in the contest satisfying the condition in the problem statement.
Examples
Input
10
1 2 5 6 7 10 21 23 24 49
Output
4
Input
5
2 10 50 110 250
Output
1
Input
6
4 7 12 100 150 199
Output
3
Note
Description of the first example: there are 10 valid contests consisting of 1 problem, 10 valid contests consisting of 2 problems ([1, 2], [5, 6], [5, 7], [5, 10], [6, 7], [6, 10], [7, 10], [21, 23], [21, 24], [23, 24]), 5 valid contests consisting of 3 problems ([5, 6, 7], [5, 6, 10], [5, 7, 10], [6, 7, 10], [21, 23, 24]) and a single valid contest consisting of 4 problems ([5, 6, 7, 10]).
In the second example all the valid contests consist of 1 problem.
In the third example are two contests consisting of 3 problems: [4, 7, 12] and [100, 150, 199].
Submitted Solution:
```
a=int(input())
b=list(map(int, input().split()))
b.append(b[a-1]+1)
#print(b)
m=1
t=1
for i in range(1, a):
#print(b[i-1],end=" ")
if (b[i-1]*2>=b[i]):
t+=1
#print("!",end="")
else:
t=1
#print("\n")
if t>m:
m=t;
print(m)
```
|
instruction
| 0
| 7,557
| 11
| 15,114
|
Yes
|
output
| 1
| 7,557
| 11
| 15,115
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a problemset consisting of n problems. The difficulty of the i-th problem is a_i. It is guaranteed that all difficulties are distinct and are given in the increasing order.
You have to assemble the contest which consists of some problems of the given problemset. In other words, the contest you have to assemble should be a subset of problems (not necessary consecutive) of the given problemset. There is only one condition that should be satisfied: for each problem but the hardest one (the problem with the maximum difficulty) there should be a problem with the difficulty greater than the difficulty of this problem but not greater than twice the difficulty of this problem. In other words, let a_{i_1}, a_{i_2}, ..., a_{i_p} be the difficulties of the selected problems in increasing order. Then for each j from 1 to p-1 a_{i_{j + 1}} ≤ a_{i_j} ⋅ 2 should hold. It means that the contest consisting of only one problem is always valid.
Among all contests satisfying the condition above you have to assemble one with the maximum number of problems. Your task is to find this number of problems.
Input
The first line of the input contains one integer n (1 ≤ n ≤ 2 ⋅ 10^5) — the number of problems in the problemset.
The second line of the input contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9) — difficulties of the problems. It is guaranteed that difficulties of the problems are distinct and are given in the increasing order.
Output
Print a single integer — maximum number of problems in the contest satisfying the condition in the problem statement.
Examples
Input
10
1 2 5 6 7 10 21 23 24 49
Output
4
Input
5
2 10 50 110 250
Output
1
Input
6
4 7 12 100 150 199
Output
3
Note
Description of the first example: there are 10 valid contests consisting of 1 problem, 10 valid contests consisting of 2 problems ([1, 2], [5, 6], [5, 7], [5, 10], [6, 7], [6, 10], [7, 10], [21, 23], [21, 24], [23, 24]), 5 valid contests consisting of 3 problems ([5, 6, 7], [5, 6, 10], [5, 7, 10], [6, 7, 10], [21, 23, 24]) and a single valid contest consisting of 4 problems ([5, 6, 7, 10]).
In the second example all the valid contests consist of 1 problem.
In the third example are two contests consisting of 3 problems: [4, 7, 12] and [100, 150, 199].
Submitted Solution:
```
n = int(input())
l = list(map(int, input().split()))
ans, cur = 0, 1
for i in range(n):
if i :
if l[i] <= (2 * l[i-1]):
cur += 1
else:
cur = 1
ans = max(ans, cur)
print(ans)
```
|
instruction
| 0
| 7,558
| 11
| 15,116
|
Yes
|
output
| 1
| 7,558
| 11
| 15,117
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a problemset consisting of n problems. The difficulty of the i-th problem is a_i. It is guaranteed that all difficulties are distinct and are given in the increasing order.
You have to assemble the contest which consists of some problems of the given problemset. In other words, the contest you have to assemble should be a subset of problems (not necessary consecutive) of the given problemset. There is only one condition that should be satisfied: for each problem but the hardest one (the problem with the maximum difficulty) there should be a problem with the difficulty greater than the difficulty of this problem but not greater than twice the difficulty of this problem. In other words, let a_{i_1}, a_{i_2}, ..., a_{i_p} be the difficulties of the selected problems in increasing order. Then for each j from 1 to p-1 a_{i_{j + 1}} ≤ a_{i_j} ⋅ 2 should hold. It means that the contest consisting of only one problem is always valid.
Among all contests satisfying the condition above you have to assemble one with the maximum number of problems. Your task is to find this number of problems.
Input
The first line of the input contains one integer n (1 ≤ n ≤ 2 ⋅ 10^5) — the number of problems in the problemset.
The second line of the input contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9) — difficulties of the problems. It is guaranteed that difficulties of the problems are distinct and are given in the increasing order.
Output
Print a single integer — maximum number of problems in the contest satisfying the condition in the problem statement.
Examples
Input
10
1 2 5 6 7 10 21 23 24 49
Output
4
Input
5
2 10 50 110 250
Output
1
Input
6
4 7 12 100 150 199
Output
3
Note
Description of the first example: there are 10 valid contests consisting of 1 problem, 10 valid contests consisting of 2 problems ([1, 2], [5, 6], [5, 7], [5, 10], [6, 7], [6, 10], [7, 10], [21, 23], [21, 24], [23, 24]), 5 valid contests consisting of 3 problems ([5, 6, 7], [5, 6, 10], [5, 7, 10], [6, 7, 10], [21, 23, 24]) and a single valid contest consisting of 4 problems ([5, 6, 7, 10]).
In the second example all the valid contests consist of 1 problem.
In the third example are two contests consisting of 3 problems: [4, 7, 12] and [100, 150, 199].
Submitted Solution:
```
length=int(input())
a=[]
a=str(input()).split()
maxi=1
count=1
a = [*map(int, a)]
for i in range(length-1):
if(a[i+1]<=a[i]*2):
count+=1
else:
maxi=max(count, maxi)
count=1
maxi=max(count, maxi)
print(maxi)
```
|
instruction
| 0
| 7,559
| 11
| 15,118
|
Yes
|
output
| 1
| 7,559
| 11
| 15,119
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a problemset consisting of n problems. The difficulty of the i-th problem is a_i. It is guaranteed that all difficulties are distinct and are given in the increasing order.
You have to assemble the contest which consists of some problems of the given problemset. In other words, the contest you have to assemble should be a subset of problems (not necessary consecutive) of the given problemset. There is only one condition that should be satisfied: for each problem but the hardest one (the problem with the maximum difficulty) there should be a problem with the difficulty greater than the difficulty of this problem but not greater than twice the difficulty of this problem. In other words, let a_{i_1}, a_{i_2}, ..., a_{i_p} be the difficulties of the selected problems in increasing order. Then for each j from 1 to p-1 a_{i_{j + 1}} ≤ a_{i_j} ⋅ 2 should hold. It means that the contest consisting of only one problem is always valid.
Among all contests satisfying the condition above you have to assemble one with the maximum number of problems. Your task is to find this number of problems.
Input
The first line of the input contains one integer n (1 ≤ n ≤ 2 ⋅ 10^5) — the number of problems in the problemset.
The second line of the input contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9) — difficulties of the problems. It is guaranteed that difficulties of the problems are distinct and are given in the increasing order.
Output
Print a single integer — maximum number of problems in the contest satisfying the condition in the problem statement.
Examples
Input
10
1 2 5 6 7 10 21 23 24 49
Output
4
Input
5
2 10 50 110 250
Output
1
Input
6
4 7 12 100 150 199
Output
3
Note
Description of the first example: there are 10 valid contests consisting of 1 problem, 10 valid contests consisting of 2 problems ([1, 2], [5, 6], [5, 7], [5, 10], [6, 7], [6, 10], [7, 10], [21, 23], [21, 24], [23, 24]), 5 valid contests consisting of 3 problems ([5, 6, 7], [5, 6, 10], [5, 7, 10], [6, 7, 10], [21, 23, 24]) and a single valid contest consisting of 4 problems ([5, 6, 7, 10]).
In the second example all the valid contests consist of 1 problem.
In the third example are two contests consisting of 3 problems: [4, 7, 12] and [100, 150, 199].
Submitted Solution:
```
n = int(input())
l = list(map(int,input().split()))
max=1
i=0
while(i<n-1):
count=1
while(i<n-1 and 2*l[i]>=l[i+1]):
count+=1
i+=1
if max<count:
max=count
i+=1
print(max)
```
|
instruction
| 0
| 7,560
| 11
| 15,120
|
Yes
|
output
| 1
| 7,560
| 11
| 15,121
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a problemset consisting of n problems. The difficulty of the i-th problem is a_i. It is guaranteed that all difficulties are distinct and are given in the increasing order.
You have to assemble the contest which consists of some problems of the given problemset. In other words, the contest you have to assemble should be a subset of problems (not necessary consecutive) of the given problemset. There is only one condition that should be satisfied: for each problem but the hardest one (the problem with the maximum difficulty) there should be a problem with the difficulty greater than the difficulty of this problem but not greater than twice the difficulty of this problem. In other words, let a_{i_1}, a_{i_2}, ..., a_{i_p} be the difficulties of the selected problems in increasing order. Then for each j from 1 to p-1 a_{i_{j + 1}} ≤ a_{i_j} ⋅ 2 should hold. It means that the contest consisting of only one problem is always valid.
Among all contests satisfying the condition above you have to assemble one with the maximum number of problems. Your task is to find this number of problems.
Input
The first line of the input contains one integer n (1 ≤ n ≤ 2 ⋅ 10^5) — the number of problems in the problemset.
The second line of the input contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9) — difficulties of the problems. It is guaranteed that difficulties of the problems are distinct and are given in the increasing order.
Output
Print a single integer — maximum number of problems in the contest satisfying the condition in the problem statement.
Examples
Input
10
1 2 5 6 7 10 21 23 24 49
Output
4
Input
5
2 10 50 110 250
Output
1
Input
6
4 7 12 100 150 199
Output
3
Note
Description of the first example: there are 10 valid contests consisting of 1 problem, 10 valid contests consisting of 2 problems ([1, 2], [5, 6], [5, 7], [5, 10], [6, 7], [6, 10], [7, 10], [21, 23], [21, 24], [23, 24]), 5 valid contests consisting of 3 problems ([5, 6, 7], [5, 6, 10], [5, 7, 10], [6, 7, 10], [21, 23, 24]) and a single valid contest consisting of 4 problems ([5, 6, 7, 10]).
In the second example all the valid contests consist of 1 problem.
In the third example are two contests consisting of 3 problems: [4, 7, 12] and [100, 150, 199].
Submitted Solution:
```
n = int(input())
sn = input()
an = sn.split()
l = list()
count = 0
if len(an)!=n:
print("error")
for i in range(1,len(an)):
n1 = 2*int(an[i-1])
if (int(an[i]) <= n1) :
l.append(i-1)
continue
else:
continue
k = list()
for j in range(1,len(l)):
print(l[j],l[j-1])
if l[j]==(l[j-1]+1):
count = count+2
continue
else:
k.append(count+1)
count = 0
continue
print(k)
print(max(k))
```
|
instruction
| 0
| 7,561
| 11
| 15,122
|
No
|
output
| 1
| 7,561
| 11
| 15,123
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a problemset consisting of n problems. The difficulty of the i-th problem is a_i. It is guaranteed that all difficulties are distinct and are given in the increasing order.
You have to assemble the contest which consists of some problems of the given problemset. In other words, the contest you have to assemble should be a subset of problems (not necessary consecutive) of the given problemset. There is only one condition that should be satisfied: for each problem but the hardest one (the problem with the maximum difficulty) there should be a problem with the difficulty greater than the difficulty of this problem but not greater than twice the difficulty of this problem. In other words, let a_{i_1}, a_{i_2}, ..., a_{i_p} be the difficulties of the selected problems in increasing order. Then for each j from 1 to p-1 a_{i_{j + 1}} ≤ a_{i_j} ⋅ 2 should hold. It means that the contest consisting of only one problem is always valid.
Among all contests satisfying the condition above you have to assemble one with the maximum number of problems. Your task is to find this number of problems.
Input
The first line of the input contains one integer n (1 ≤ n ≤ 2 ⋅ 10^5) — the number of problems in the problemset.
The second line of the input contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9) — difficulties of the problems. It is guaranteed that difficulties of the problems are distinct and are given in the increasing order.
Output
Print a single integer — maximum number of problems in the contest satisfying the condition in the problem statement.
Examples
Input
10
1 2 5 6 7 10 21 23 24 49
Output
4
Input
5
2 10 50 110 250
Output
1
Input
6
4 7 12 100 150 199
Output
3
Note
Description of the first example: there are 10 valid contests consisting of 1 problem, 10 valid contests consisting of 2 problems ([1, 2], [5, 6], [5, 7], [5, 10], [6, 7], [6, 10], [7, 10], [21, 23], [21, 24], [23, 24]), 5 valid contests consisting of 3 problems ([5, 6, 7], [5, 6, 10], [5, 7, 10], [6, 7, 10], [21, 23, 24]) and a single valid contest consisting of 4 problems ([5, 6, 7, 10]).
In the second example all the valid contests consist of 1 problem.
In the third example are two contests consisting of 3 problems: [4, 7, 12] and [100, 150, 199].
Submitted Solution:
```
# левый догоняет правый индекс поэтому 0(n)
n = int(input())
a = list(map(int,input().split()))
L,R,ans=0,0,1
while True:
if R==n-1:
ans=max(ans,R-L+1)
break
if a[R]*2>a[R+1]:
R+=1
else:
ans=max(ans,R-L+1)
R+=1
L=R
print(ans)
```
|
instruction
| 0
| 7,562
| 11
| 15,124
|
No
|
output
| 1
| 7,562
| 11
| 15,125
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a problemset consisting of n problems. The difficulty of the i-th problem is a_i. It is guaranteed that all difficulties are distinct and are given in the increasing order.
You have to assemble the contest which consists of some problems of the given problemset. In other words, the contest you have to assemble should be a subset of problems (not necessary consecutive) of the given problemset. There is only one condition that should be satisfied: for each problem but the hardest one (the problem with the maximum difficulty) there should be a problem with the difficulty greater than the difficulty of this problem but not greater than twice the difficulty of this problem. In other words, let a_{i_1}, a_{i_2}, ..., a_{i_p} be the difficulties of the selected problems in increasing order. Then for each j from 1 to p-1 a_{i_{j + 1}} ≤ a_{i_j} ⋅ 2 should hold. It means that the contest consisting of only one problem is always valid.
Among all contests satisfying the condition above you have to assemble one with the maximum number of problems. Your task is to find this number of problems.
Input
The first line of the input contains one integer n (1 ≤ n ≤ 2 ⋅ 10^5) — the number of problems in the problemset.
The second line of the input contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9) — difficulties of the problems. It is guaranteed that difficulties of the problems are distinct and are given in the increasing order.
Output
Print a single integer — maximum number of problems in the contest satisfying the condition in the problem statement.
Examples
Input
10
1 2 5 6 7 10 21 23 24 49
Output
4
Input
5
2 10 50 110 250
Output
1
Input
6
4 7 12 100 150 199
Output
3
Note
Description of the first example: there are 10 valid contests consisting of 1 problem, 10 valid contests consisting of 2 problems ([1, 2], [5, 6], [5, 7], [5, 10], [6, 7], [6, 10], [7, 10], [21, 23], [21, 24], [23, 24]), 5 valid contests consisting of 3 problems ([5, 6, 7], [5, 6, 10], [5, 7, 10], [6, 7, 10], [21, 23, 24]) and a single valid contest consisting of 4 problems ([5, 6, 7, 10]).
In the second example all the valid contests consist of 1 problem.
In the third example are two contests consisting of 3 problems: [4, 7, 12] and [100, 150, 199].
Submitted Solution:
```
k=int(input())
s=input()
l=s.split()
l=list(map(int,l))
z=1
maxa=0
for i in range(len(l)-1):
if((l[i+1])<=l[i]*2):
z+=1
else:
maxa=max(z,maxa)
z=1
print(maxa)
```
|
instruction
| 0
| 7,563
| 11
| 15,126
|
No
|
output
| 1
| 7,563
| 11
| 15,127
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a problemset consisting of n problems. The difficulty of the i-th problem is a_i. It is guaranteed that all difficulties are distinct and are given in the increasing order.
You have to assemble the contest which consists of some problems of the given problemset. In other words, the contest you have to assemble should be a subset of problems (not necessary consecutive) of the given problemset. There is only one condition that should be satisfied: for each problem but the hardest one (the problem with the maximum difficulty) there should be a problem with the difficulty greater than the difficulty of this problem but not greater than twice the difficulty of this problem. In other words, let a_{i_1}, a_{i_2}, ..., a_{i_p} be the difficulties of the selected problems in increasing order. Then for each j from 1 to p-1 a_{i_{j + 1}} ≤ a_{i_j} ⋅ 2 should hold. It means that the contest consisting of only one problem is always valid.
Among all contests satisfying the condition above you have to assemble one with the maximum number of problems. Your task is to find this number of problems.
Input
The first line of the input contains one integer n (1 ≤ n ≤ 2 ⋅ 10^5) — the number of problems in the problemset.
The second line of the input contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9) — difficulties of the problems. It is guaranteed that difficulties of the problems are distinct and are given in the increasing order.
Output
Print a single integer — maximum number of problems in the contest satisfying the condition in the problem statement.
Examples
Input
10
1 2 5 6 7 10 21 23 24 49
Output
4
Input
5
2 10 50 110 250
Output
1
Input
6
4 7 12 100 150 199
Output
3
Note
Description of the first example: there are 10 valid contests consisting of 1 problem, 10 valid contests consisting of 2 problems ([1, 2], [5, 6], [5, 7], [5, 10], [6, 7], [6, 10], [7, 10], [21, 23], [21, 24], [23, 24]), 5 valid contests consisting of 3 problems ([5, 6, 7], [5, 6, 10], [5, 7, 10], [6, 7, 10], [21, 23, 24]) and a single valid contest consisting of 4 problems ([5, 6, 7, 10]).
In the second example all the valid contests consist of 1 problem.
In the third example are two contests consisting of 3 problems: [4, 7, 12] and [100, 150, 199].
Submitted Solution:
```
import bisect
n=int(input())
arr=list(map(int,input().split()))
d={};ans=0
for i in arr:d[i]=d.get(i,0)+1
#print(d)
arr=sorted(arr)
for i in range(n):
k=2*arr[i]
idx=bisect.bisect(arr,k)
ans=max(ans,idx-i)
print(ans)
```
|
instruction
| 0
| 7,564
| 11
| 15,128
|
No
|
output
| 1
| 7,564
| 11
| 15,129
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Not so long ago company R2 bought company R1 and consequently, all its developments in the field of multicore processors. Now the R2 laboratory is testing one of the R1 processors.
The testing goes in n steps, at each step the processor gets some instructions, and then its temperature is measured. The head engineer in R2 is keeping a report record on the work of the processor: he writes down the minimum and the maximum measured temperature in his notebook. His assistant had to write down all temperatures into his notebook, but (for unknown reasons) he recorded only m.
The next day, the engineer's assistant filed in a report with all the m temperatures. However, the chief engineer doubts that the assistant wrote down everything correctly (naturally, the chief engineer doesn't doubt his notes). So he asked you to help him. Given numbers n, m, min, max and the list of m temperatures determine whether you can upgrade the set of m temperatures to the set of n temperatures (that is add n - m temperatures), so that the minimum temperature was min and the maximum one was max.
Input
The first line contains four integers n, m, min, max (1 ≤ m < n ≤ 100; 1 ≤ min < max ≤ 100). The second line contains m space-separated integers ti (1 ≤ ti ≤ 100) — the temperatures reported by the assistant.
Note, that the reported temperatures, and the temperatures you want to add can contain equal temperatures.
Output
If the data is consistent, print 'Correct' (without the quotes). Otherwise, print 'Incorrect' (without the quotes).
Examples
Input
2 1 1 2
1
Output
Correct
Input
3 1 1 3
2
Output
Correct
Input
2 1 1 3
2
Output
Incorrect
Note
In the first test sample one of the possible initial configurations of temperatures is [1, 2].
In the second test sample one of the possible initial configurations of temperatures is [2, 1, 3].
In the third test sample it is impossible to add one temperature to obtain the minimum equal to 1 and the maximum equal to 3.
Submitted Solution:
```
n, m, Min, Max = map(int, input().split())
a = list(map(int, input().split()))
remain = n - m
cnt = 0
flag = 0
for i in a:
if i == Min or i == Max:
cnt += 1
if i < Min or i > Max:
flag = -1
cnt = 2 - cnt
if flag == -1:
print("Incorrect")
else:
if n - m >= cnt:
print("Correct")
else:
print("Incorrect")
```
|
instruction
| 0
| 7,911
| 11
| 15,822
|
Yes
|
output
| 1
| 7,911
| 11
| 15,823
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Not so long ago company R2 bought company R1 and consequently, all its developments in the field of multicore processors. Now the R2 laboratory is testing one of the R1 processors.
The testing goes in n steps, at each step the processor gets some instructions, and then its temperature is measured. The head engineer in R2 is keeping a report record on the work of the processor: he writes down the minimum and the maximum measured temperature in his notebook. His assistant had to write down all temperatures into his notebook, but (for unknown reasons) he recorded only m.
The next day, the engineer's assistant filed in a report with all the m temperatures. However, the chief engineer doubts that the assistant wrote down everything correctly (naturally, the chief engineer doesn't doubt his notes). So he asked you to help him. Given numbers n, m, min, max and the list of m temperatures determine whether you can upgrade the set of m temperatures to the set of n temperatures (that is add n - m temperatures), so that the minimum temperature was min and the maximum one was max.
Input
The first line contains four integers n, m, min, max (1 ≤ m < n ≤ 100; 1 ≤ min < max ≤ 100). The second line contains m space-separated integers ti (1 ≤ ti ≤ 100) — the temperatures reported by the assistant.
Note, that the reported temperatures, and the temperatures you want to add can contain equal temperatures.
Output
If the data is consistent, print 'Correct' (without the quotes). Otherwise, print 'Incorrect' (without the quotes).
Examples
Input
2 1 1 2
1
Output
Correct
Input
3 1 1 3
2
Output
Correct
Input
2 1 1 3
2
Output
Incorrect
Note
In the first test sample one of the possible initial configurations of temperatures is [1, 2].
In the second test sample one of the possible initial configurations of temperatures is [2, 1, 3].
In the third test sample it is impossible to add one temperature to obtain the minimum equal to 1 and the maximum equal to 3.
Submitted Solution:
```
n, m, v1, v2 = map(int, input().split())
t = list(map(int, input().split()))
t1, t2 = min(t), max(t)
if t1 < v1 or t2 > v2:
print('Incorrect')
elif (v1 < t1) + (v2 > t2) > n - m:
print('Incorrect')
else:
print('Correct')
```
|
instruction
| 0
| 7,912
| 11
| 15,824
|
Yes
|
output
| 1
| 7,912
| 11
| 15,825
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Not so long ago company R2 bought company R1 and consequently, all its developments in the field of multicore processors. Now the R2 laboratory is testing one of the R1 processors.
The testing goes in n steps, at each step the processor gets some instructions, and then its temperature is measured. The head engineer in R2 is keeping a report record on the work of the processor: he writes down the minimum and the maximum measured temperature in his notebook. His assistant had to write down all temperatures into his notebook, but (for unknown reasons) he recorded only m.
The next day, the engineer's assistant filed in a report with all the m temperatures. However, the chief engineer doubts that the assistant wrote down everything correctly (naturally, the chief engineer doesn't doubt his notes). So he asked you to help him. Given numbers n, m, min, max and the list of m temperatures determine whether you can upgrade the set of m temperatures to the set of n temperatures (that is add n - m temperatures), so that the minimum temperature was min and the maximum one was max.
Input
The first line contains four integers n, m, min, max (1 ≤ m < n ≤ 100; 1 ≤ min < max ≤ 100). The second line contains m space-separated integers ti (1 ≤ ti ≤ 100) — the temperatures reported by the assistant.
Note, that the reported temperatures, and the temperatures you want to add can contain equal temperatures.
Output
If the data is consistent, print 'Correct' (without the quotes). Otherwise, print 'Incorrect' (without the quotes).
Examples
Input
2 1 1 2
1
Output
Correct
Input
3 1 1 3
2
Output
Correct
Input
2 1 1 3
2
Output
Incorrect
Note
In the first test sample one of the possible initial configurations of temperatures is [1, 2].
In the second test sample one of the possible initial configurations of temperatures is [2, 1, 3].
In the third test sample it is impossible to add one temperature to obtain the minimum equal to 1 and the maximum equal to 3.
Submitted Solution:
```
n, m, min_, max_ = map(int, input().split())
l = sorted(list(map(int, input().split())))
if l[0] < min_ or l[-1] > max_:
print("Incorrect")
else:
if l[-1] < max_:
l.append(max_)
if l[0] > min_:
l.append(min_)
if len(l) <= n:
print("Correct")
else:
print("Incorrect")
```
|
instruction
| 0
| 7,913
| 11
| 15,826
|
Yes
|
output
| 1
| 7,913
| 11
| 15,827
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Not so long ago company R2 bought company R1 and consequently, all its developments in the field of multicore processors. Now the R2 laboratory is testing one of the R1 processors.
The testing goes in n steps, at each step the processor gets some instructions, and then its temperature is measured. The head engineer in R2 is keeping a report record on the work of the processor: he writes down the minimum and the maximum measured temperature in his notebook. His assistant had to write down all temperatures into his notebook, but (for unknown reasons) he recorded only m.
The next day, the engineer's assistant filed in a report with all the m temperatures. However, the chief engineer doubts that the assistant wrote down everything correctly (naturally, the chief engineer doesn't doubt his notes). So he asked you to help him. Given numbers n, m, min, max and the list of m temperatures determine whether you can upgrade the set of m temperatures to the set of n temperatures (that is add n - m temperatures), so that the minimum temperature was min and the maximum one was max.
Input
The first line contains four integers n, m, min, max (1 ≤ m < n ≤ 100; 1 ≤ min < max ≤ 100). The second line contains m space-separated integers ti (1 ≤ ti ≤ 100) — the temperatures reported by the assistant.
Note, that the reported temperatures, and the temperatures you want to add can contain equal temperatures.
Output
If the data is consistent, print 'Correct' (without the quotes). Otherwise, print 'Incorrect' (without the quotes).
Examples
Input
2 1 1 2
1
Output
Correct
Input
3 1 1 3
2
Output
Correct
Input
2 1 1 3
2
Output
Incorrect
Note
In the first test sample one of the possible initial configurations of temperatures is [1, 2].
In the second test sample one of the possible initial configurations of temperatures is [2, 1, 3].
In the third test sample it is impossible to add one temperature to obtain the minimum equal to 1 and the maximum equal to 3.
Submitted Solution:
```
n, m , minimum, maximum = map(int, input().split())
list_of_m = list(map(int, input().split()))
maxi = max(list_of_m)
mini = min(list_of_m)
if maxi < maximum and mini > minimum :
if n - m >= 2:
print("Correct")
else:
print("Incorrect")
elif maxi == maximum and mini > minimum :
if n - m >= 1:
print("Correct")
else:
print("Incorrect")
elif maxi < maximum and mini == minimum :
if n - m >= 1:
print("Correct")
else:
print("Incorrect")
elif maxi == maximum and mini == minimum :
print("Correct")
else:
print("Incorrect")
```
|
instruction
| 0
| 7,914
| 11
| 15,828
|
Yes
|
output
| 1
| 7,914
| 11
| 15,829
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Not so long ago company R2 bought company R1 and consequently, all its developments in the field of multicore processors. Now the R2 laboratory is testing one of the R1 processors.
The testing goes in n steps, at each step the processor gets some instructions, and then its temperature is measured. The head engineer in R2 is keeping a report record on the work of the processor: he writes down the minimum and the maximum measured temperature in his notebook. His assistant had to write down all temperatures into his notebook, but (for unknown reasons) he recorded only m.
The next day, the engineer's assistant filed in a report with all the m temperatures. However, the chief engineer doubts that the assistant wrote down everything correctly (naturally, the chief engineer doesn't doubt his notes). So he asked you to help him. Given numbers n, m, min, max and the list of m temperatures determine whether you can upgrade the set of m temperatures to the set of n temperatures (that is add n - m temperatures), so that the minimum temperature was min and the maximum one was max.
Input
The first line contains four integers n, m, min, max (1 ≤ m < n ≤ 100; 1 ≤ min < max ≤ 100). The second line contains m space-separated integers ti (1 ≤ ti ≤ 100) — the temperatures reported by the assistant.
Note, that the reported temperatures, and the temperatures you want to add can contain equal temperatures.
Output
If the data is consistent, print 'Correct' (without the quotes). Otherwise, print 'Incorrect' (without the quotes).
Examples
Input
2 1 1 2
1
Output
Correct
Input
3 1 1 3
2
Output
Correct
Input
2 1 1 3
2
Output
Incorrect
Note
In the first test sample one of the possible initial configurations of temperatures is [1, 2].
In the second test sample one of the possible initial configurations of temperatures is [2, 1, 3].
In the third test sample it is impossible to add one temperature to obtain the minimum equal to 1 and the maximum equal to 3.
Submitted Solution:
```
import random
import time
nn,nm,min,max = list(map(int,input().split()))
m = list(map(int,input().split()))
i = min
if nn == nm:
print('Correct')
quit()
if nm > nn:
print('Incorrect')
quit()
for x in m:
if i< min or i> max:
print('Incorrect')
quit()
if min not in m:
m.append(min)
if max not in m:
m.append(max)
while i !=max and len(m) <nn:
if i not in m:
m.append(i)
i+=1
if len(m) == nn:
print('Correct')
else:
print('Incorrect')
```
|
instruction
| 0
| 7,915
| 11
| 15,830
|
No
|
output
| 1
| 7,915
| 11
| 15,831
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Not so long ago company R2 bought company R1 and consequently, all its developments in the field of multicore processors. Now the R2 laboratory is testing one of the R1 processors.
The testing goes in n steps, at each step the processor gets some instructions, and then its temperature is measured. The head engineer in R2 is keeping a report record on the work of the processor: he writes down the minimum and the maximum measured temperature in his notebook. His assistant had to write down all temperatures into his notebook, but (for unknown reasons) he recorded only m.
The next day, the engineer's assistant filed in a report with all the m temperatures. However, the chief engineer doubts that the assistant wrote down everything correctly (naturally, the chief engineer doesn't doubt his notes). So he asked you to help him. Given numbers n, m, min, max and the list of m temperatures determine whether you can upgrade the set of m temperatures to the set of n temperatures (that is add n - m temperatures), so that the minimum temperature was min and the maximum one was max.
Input
The first line contains four integers n, m, min, max (1 ≤ m < n ≤ 100; 1 ≤ min < max ≤ 100). The second line contains m space-separated integers ti (1 ≤ ti ≤ 100) — the temperatures reported by the assistant.
Note, that the reported temperatures, and the temperatures you want to add can contain equal temperatures.
Output
If the data is consistent, print 'Correct' (without the quotes). Otherwise, print 'Incorrect' (without the quotes).
Examples
Input
2 1 1 2
1
Output
Correct
Input
3 1 1 3
2
Output
Correct
Input
2 1 1 3
2
Output
Incorrect
Note
In the first test sample one of the possible initial configurations of temperatures is [1, 2].
In the second test sample one of the possible initial configurations of temperatures is [2, 1, 3].
In the third test sample it is impossible to add one temperature to obtain the minimum equal to 1 and the maximum equal to 3.
Submitted Solution:
```
n,m,mi,mx= map(int,input().split())
t= list(map(int,input().split()))
a = min(t)
b = max(t)
h=0
if a==mi:
h+=1
if b==mx:
h+=1
if h==2:print('Correct')
else:
if h==1:
if n-m>=1:
print('Correct')
else:
print('Incorrect')
else:
if n-m>=2:
print('Correct')
else:
print('Incorrect')
```
|
instruction
| 0
| 7,916
| 11
| 15,832
|
No
|
output
| 1
| 7,916
| 11
| 15,833
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Not so long ago company R2 bought company R1 and consequently, all its developments in the field of multicore processors. Now the R2 laboratory is testing one of the R1 processors.
The testing goes in n steps, at each step the processor gets some instructions, and then its temperature is measured. The head engineer in R2 is keeping a report record on the work of the processor: he writes down the minimum and the maximum measured temperature in his notebook. His assistant had to write down all temperatures into his notebook, but (for unknown reasons) he recorded only m.
The next day, the engineer's assistant filed in a report with all the m temperatures. However, the chief engineer doubts that the assistant wrote down everything correctly (naturally, the chief engineer doesn't doubt his notes). So he asked you to help him. Given numbers n, m, min, max and the list of m temperatures determine whether you can upgrade the set of m temperatures to the set of n temperatures (that is add n - m temperatures), so that the minimum temperature was min and the maximum one was max.
Input
The first line contains four integers n, m, min, max (1 ≤ m < n ≤ 100; 1 ≤ min < max ≤ 100). The second line contains m space-separated integers ti (1 ≤ ti ≤ 100) — the temperatures reported by the assistant.
Note, that the reported temperatures, and the temperatures you want to add can contain equal temperatures.
Output
If the data is consistent, print 'Correct' (without the quotes). Otherwise, print 'Incorrect' (without the quotes).
Examples
Input
2 1 1 2
1
Output
Correct
Input
3 1 1 3
2
Output
Correct
Input
2 1 1 3
2
Output
Incorrect
Note
In the first test sample one of the possible initial configurations of temperatures is [1, 2].
In the second test sample one of the possible initial configurations of temperatures is [2, 1, 3].
In the third test sample it is impossible to add one temperature to obtain the minimum equal to 1 and the maximum equal to 3.
Submitted Solution:
```
n, m, minimum, maximum = map(int, input().split())
seq = [int(i) for i in input().split()]
if max(seq) < maximum and min(seq) > minimum:
print('Correct')
elif minimum in seq and maximum in seq:
print('Correct')
elif minimum not in seq and maximum not in seq:
if n - m >= 2:
print('Correct')
else:
print('Incorrect')
elif (minimum in seq and maximum not in seq) or (minimum not in seq and maximum in seq):
if n - m >= 1:
print('Correct')
else:
print('Incorrect')
```
|
instruction
| 0
| 7,917
| 11
| 15,834
|
No
|
output
| 1
| 7,917
| 11
| 15,835
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Not so long ago company R2 bought company R1 and consequently, all its developments in the field of multicore processors. Now the R2 laboratory is testing one of the R1 processors.
The testing goes in n steps, at each step the processor gets some instructions, and then its temperature is measured. The head engineer in R2 is keeping a report record on the work of the processor: he writes down the minimum and the maximum measured temperature in his notebook. His assistant had to write down all temperatures into his notebook, but (for unknown reasons) he recorded only m.
The next day, the engineer's assistant filed in a report with all the m temperatures. However, the chief engineer doubts that the assistant wrote down everything correctly (naturally, the chief engineer doesn't doubt his notes). So he asked you to help him. Given numbers n, m, min, max and the list of m temperatures determine whether you can upgrade the set of m temperatures to the set of n temperatures (that is add n - m temperatures), so that the minimum temperature was min and the maximum one was max.
Input
The first line contains four integers n, m, min, max (1 ≤ m < n ≤ 100; 1 ≤ min < max ≤ 100). The second line contains m space-separated integers ti (1 ≤ ti ≤ 100) — the temperatures reported by the assistant.
Note, that the reported temperatures, and the temperatures you want to add can contain equal temperatures.
Output
If the data is consistent, print 'Correct' (without the quotes). Otherwise, print 'Incorrect' (without the quotes).
Examples
Input
2 1 1 2
1
Output
Correct
Input
3 1 1 3
2
Output
Correct
Input
2 1 1 3
2
Output
Incorrect
Note
In the first test sample one of the possible initial configurations of temperatures is [1, 2].
In the second test sample one of the possible initial configurations of temperatures is [2, 1, 3].
In the third test sample it is impossible to add one temperature to obtain the minimum equal to 1 and the maximum equal to 3.
Submitted Solution:
```
def main():
n,m,mn,mx=map(int,input().split())
s=sorted([int(i)for i in input().split()])
if n-m>2 or mx<s[-1] or mn>s[0]:
return "Incorrect"
if mn<s[0] and mx>s[-1]:
if n-m==2:
return "Correct"
else:
return "Incorrect"
else:
return "Correct"
print(main())
```
|
instruction
| 0
| 7,918
| 11
| 15,836
|
No
|
output
| 1
| 7,918
| 11
| 15,837
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
This is an interactive problem. In the interaction section below you will see the information about flushing the output.
In this problem, you will be playing a game with Hongcow. How lucky of you!
Hongcow has a hidden n by n matrix M. Let Mi, j denote the entry i-th row and j-th column of the matrix. The rows and columns are labeled from 1 to n.
The matrix entries are between 0 and 109. In addition, Mi, i = 0 for all valid i. Your task is to find the minimum value along each row, excluding diagonal elements. Formally, for each i, you must find <image>.
To do this, you can ask Hongcow some questions.
A question consists of giving Hongcow a subset of distinct indices {w1, w2, ..., wk}, with 1 ≤ k ≤ n. Hongcow will respond with n integers. The i-th integer will contain the minimum value of min1 ≤ j ≤ kMi, wj.
You may only ask Hongcow at most 20 questions — he thinks you only need that many questions answered.
When you are ready to answer, print out a single integer - 1 on its own line, then n integers on the next line. The i-th integer should be the minimum value in the i-th row of the matrix, excluding the i-th element. Do not forget to flush the final answer as well. Printing the answer does not count as asking a question.
You will get Wrong Answer verdict if
* Your question or answers are not in the format described in this statement.
* You ask strictly more than 20 questions.
* Your question contains duplicate indices.
* The value of k in your question does not lie in the range from 1 to n, inclusive.
* Your final answer is not correct.
You will get Idleness Limit Exceeded if you don't print anything or if you forget to flush the output, including for the final answer (more info about flushing output below).
Input
The first line of input will contain a single integer n (2 ≤ n ≤ 1, 000).
Output
To print the final answer, print out the string -1 on its own line. Then, the next line should contain n integers. The i-th integer should be the minimum value of the i-th row of the matrix, excluding elements on the diagonal. Do not forget to flush your answer!
Interaction
To ask a question, print out a single integer k on its own line, denoting the size of your subset. Then, the next line should contain k integers w1, w2, ... wk. Note, you must flush your output to get a response.
Hongcow will respond by printing out a line with n integers. The i-th integer in this line represents the minimum value of Mi, wj where j is between 1 and k.
You may only ask a question at most 20 times, otherwise, you will get Wrong Answer.
To flush you can use (just after printing an integer and end-of-line):
* fflush(stdout) in C++;
* System.out.flush() in Java;
* stdout.flush() in Python;
* flush(output) in Pascal;
* See the documentation for other languages.
Hacking To hack someone, use the following format
n
M_{1,1} M_{1,2} ... M_{1,n}
M_{2,1} M_{2,2} ... M_{2,n}
...
M_{n,1} M_{n,2} ... M_{n,n}
Of course, contestant programs will not be able to see this input.
Examples
Input
3
0 0 0
2 7 0
0 0 4
3 0 8
0 5 4
Output
3
1 2 3
1
3
2
1 2
1
2
1
1
-1
2 5 4
Input
2
0 0
0 0
Output
1
2
1
1
-1
0 0
Note
In the first sample, Hongcow has the hidden matrix
[
[0, 3, 2],
[5, 0, 7],
[4, 8 ,0],
]
Here is a more readable version demonstrating the interaction. The column on the left represents Hongcow, while the column on the right represents the contestant.
3
3
1 2 3
0 0 0
1
3
2 7 0
2
1 2
0 0 4
1
2
3 0 8
1
1
0 5 4
-1
2 5 4
For the second sample, it is possible for off-diagonal elements of the matrix to be zero.
Submitted Solution:
```
from sys import stdout
def g(k, p):
print(str(k) + '\n' + ' '.join(map(str, p)))
stdout.flush()
n = int(input())
s = [9e9] * n
def f(q):
global s
p = [k + 1 for k, v in enumerate(q) if v]
g(len(p), p)
s = [i if j else min(i, int(k)) for i, j, k in zip(s, q, input().split())]
return [not v for v in q]
k = 1
while k < n:
f(f([not (i & k) for i in range(n)]))
k *= 2
g(-1, s)
```
|
instruction
| 0
| 8,055
| 11
| 16,110
|
Yes
|
output
| 1
| 8,055
| 11
| 16,111
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
This is an interactive problem. In the interaction section below you will see the information about flushing the output.
In this problem, you will be playing a game with Hongcow. How lucky of you!
Hongcow has a hidden n by n matrix M. Let Mi, j denote the entry i-th row and j-th column of the matrix. The rows and columns are labeled from 1 to n.
The matrix entries are between 0 and 109. In addition, Mi, i = 0 for all valid i. Your task is to find the minimum value along each row, excluding diagonal elements. Formally, for each i, you must find <image>.
To do this, you can ask Hongcow some questions.
A question consists of giving Hongcow a subset of distinct indices {w1, w2, ..., wk}, with 1 ≤ k ≤ n. Hongcow will respond with n integers. The i-th integer will contain the minimum value of min1 ≤ j ≤ kMi, wj.
You may only ask Hongcow at most 20 questions — he thinks you only need that many questions answered.
When you are ready to answer, print out a single integer - 1 on its own line, then n integers on the next line. The i-th integer should be the minimum value in the i-th row of the matrix, excluding the i-th element. Do not forget to flush the final answer as well. Printing the answer does not count as asking a question.
You will get Wrong Answer verdict if
* Your question or answers are not in the format described in this statement.
* You ask strictly more than 20 questions.
* Your question contains duplicate indices.
* The value of k in your question does not lie in the range from 1 to n, inclusive.
* Your final answer is not correct.
You will get Idleness Limit Exceeded if you don't print anything or if you forget to flush the output, including for the final answer (more info about flushing output below).
Input
The first line of input will contain a single integer n (2 ≤ n ≤ 1, 000).
Output
To print the final answer, print out the string -1 on its own line. Then, the next line should contain n integers. The i-th integer should be the minimum value of the i-th row of the matrix, excluding elements on the diagonal. Do not forget to flush your answer!
Interaction
To ask a question, print out a single integer k on its own line, denoting the size of your subset. Then, the next line should contain k integers w1, w2, ... wk. Note, you must flush your output to get a response.
Hongcow will respond by printing out a line with n integers. The i-th integer in this line represents the minimum value of Mi, wj where j is between 1 and k.
You may only ask a question at most 20 times, otherwise, you will get Wrong Answer.
To flush you can use (just after printing an integer and end-of-line):
* fflush(stdout) in C++;
* System.out.flush() in Java;
* stdout.flush() in Python;
* flush(output) in Pascal;
* See the documentation for other languages.
Hacking To hack someone, use the following format
n
M_{1,1} M_{1,2} ... M_{1,n}
M_{2,1} M_{2,2} ... M_{2,n}
...
M_{n,1} M_{n,2} ... M_{n,n}
Of course, contestant programs will not be able to see this input.
Examples
Input
3
0 0 0
2 7 0
0 0 4
3 0 8
0 5 4
Output
3
1 2 3
1
3
2
1 2
1
2
1
1
-1
2 5 4
Input
2
0 0
0 0
Output
1
2
1
1
-1
0 0
Note
In the first sample, Hongcow has the hidden matrix
[
[0, 3, 2],
[5, 0, 7],
[4, 8 ,0],
]
Here is a more readable version demonstrating the interaction. The column on the left represents Hongcow, while the column on the right represents the contestant.
3
3
1 2 3
0 0 0
1
3
2 7 0
2
1 2
0 0 4
1
2
3 0 8
1
1
0 5 4
-1
2 5 4
For the second sample, it is possible for off-diagonal elements of the matrix to be zero.
Submitted Solution:
```
import math,sys,re,itertools,pprint,collections,copy
rs,ri,rai,raf=input,lambda:int(input()),lambda:list(map(int, input().split())),lambda:list(map(float, input().split()))
pai=lambda x: print(" ".join(map(str, x)))
n = ri()
line_min = [float("inf") for _ in range(n)]
requests = []
def init_requests():
requests.append([
[(1, n//2)], [(n//2+1, n)]
])
while True:
l, r = requests[-1]
ln, rn = [], []
for i, j in l + r:
if j - i > 0:
ln.append(
(i, (i+j)//2)
)
rn.append(
((i+j)//2+1, j)
)
if len(ln) == 0 and len(rn) == 0:
break
requests.append([ln, rn])
def make_request(a: list):
print(len(a))
print(" ".join(map(str, a)))
sys.stdout.flush()
ans = rai()
for i in range(n):
if i+1 not in a:
line_min[i] = min(line_min[i], ans[i])
init_requests()
for l, r in requests:
la = []
for lr in l:
la += list(range(lr[0], lr[1]+1))
make_request(la)
ra = []
for rr in r:
ra += list(range(rr[0], rr[1]+1))
make_request(ra)
print(-1)
pai(line_min)
```
|
instruction
| 0
| 8,056
| 11
| 16,112
|
Yes
|
output
| 1
| 8,056
| 11
| 16,113
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
This is an interactive problem. In the interaction section below you will see the information about flushing the output.
In this problem, you will be playing a game with Hongcow. How lucky of you!
Hongcow has a hidden n by n matrix M. Let Mi, j denote the entry i-th row and j-th column of the matrix. The rows and columns are labeled from 1 to n.
The matrix entries are between 0 and 109. In addition, Mi, i = 0 for all valid i. Your task is to find the minimum value along each row, excluding diagonal elements. Formally, for each i, you must find <image>.
To do this, you can ask Hongcow some questions.
A question consists of giving Hongcow a subset of distinct indices {w1, w2, ..., wk}, with 1 ≤ k ≤ n. Hongcow will respond with n integers. The i-th integer will contain the minimum value of min1 ≤ j ≤ kMi, wj.
You may only ask Hongcow at most 20 questions — he thinks you only need that many questions answered.
When you are ready to answer, print out a single integer - 1 on its own line, then n integers on the next line. The i-th integer should be the minimum value in the i-th row of the matrix, excluding the i-th element. Do not forget to flush the final answer as well. Printing the answer does not count as asking a question.
You will get Wrong Answer verdict if
* Your question or answers are not in the format described in this statement.
* You ask strictly more than 20 questions.
* Your question contains duplicate indices.
* The value of k in your question does not lie in the range from 1 to n, inclusive.
* Your final answer is not correct.
You will get Idleness Limit Exceeded if you don't print anything or if you forget to flush the output, including for the final answer (more info about flushing output below).
Input
The first line of input will contain a single integer n (2 ≤ n ≤ 1, 000).
Output
To print the final answer, print out the string -1 on its own line. Then, the next line should contain n integers. The i-th integer should be the minimum value of the i-th row of the matrix, excluding elements on the diagonal. Do not forget to flush your answer!
Interaction
To ask a question, print out a single integer k on its own line, denoting the size of your subset. Then, the next line should contain k integers w1, w2, ... wk. Note, you must flush your output to get a response.
Hongcow will respond by printing out a line with n integers. The i-th integer in this line represents the minimum value of Mi, wj where j is between 1 and k.
You may only ask a question at most 20 times, otherwise, you will get Wrong Answer.
To flush you can use (just after printing an integer and end-of-line):
* fflush(stdout) in C++;
* System.out.flush() in Java;
* stdout.flush() in Python;
* flush(output) in Pascal;
* See the documentation for other languages.
Hacking To hack someone, use the following format
n
M_{1,1} M_{1,2} ... M_{1,n}
M_{2,1} M_{2,2} ... M_{2,n}
...
M_{n,1} M_{n,2} ... M_{n,n}
Of course, contestant programs will not be able to see this input.
Examples
Input
3
0 0 0
2 7 0
0 0 4
3 0 8
0 5 4
Output
3
1 2 3
1
3
2
1 2
1
2
1
1
-1
2 5 4
Input
2
0 0
0 0
Output
1
2
1
1
-1
0 0
Note
In the first sample, Hongcow has the hidden matrix
[
[0, 3, 2],
[5, 0, 7],
[4, 8 ,0],
]
Here is a more readable version demonstrating the interaction. The column on the left represents Hongcow, while the column on the right represents the contestant.
3
3
1 2 3
0 0 0
1
3
2 7 0
2
1 2
0 0 4
1
2
3 0 8
1
1
0 5 4
-1
2 5 4
For the second sample, it is possible for off-diagonal elements of the matrix to be zero.
Submitted Solution:
```
import sys
def f(x,y):
if not x: return y
elif not y: return x
else: return min(x,y)
count = 0
def req(old, lst):
global count
if count < 20:
print(len(lst))
print(" ".join(map(lambda x: str(x+1), lst)))
sys.stdout.flush()
current = list(map(int, input().split()))
for i in range(n):
if i in lst:
current[i] = BIG
old = list(map(min, old, current))
count += 1
return old
BIG = 10000000000
n = int(input())
mask = 1
res = [BIG] * n
while mask <= n:
a = [x for x in range(n) if x & mask]
b = [x for x in range(n) if not x & mask]
if a and b:
res = req(res, a)
res = req(res, b)
if count == 20: break
mask <<= 1
print(-1)
print(" ".join(map(str, res)))
sys.stdout.flush()
```
|
instruction
| 0
| 8,057
| 11
| 16,114
|
Yes
|
output
| 1
| 8,057
| 11
| 16,115
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
This is an interactive problem. In the interaction section below you will see the information about flushing the output.
In this problem, you will be playing a game with Hongcow. How lucky of you!
Hongcow has a hidden n by n matrix M. Let Mi, j denote the entry i-th row and j-th column of the matrix. The rows and columns are labeled from 1 to n.
The matrix entries are between 0 and 109. In addition, Mi, i = 0 for all valid i. Your task is to find the minimum value along each row, excluding diagonal elements. Formally, for each i, you must find <image>.
To do this, you can ask Hongcow some questions.
A question consists of giving Hongcow a subset of distinct indices {w1, w2, ..., wk}, with 1 ≤ k ≤ n. Hongcow will respond with n integers. The i-th integer will contain the minimum value of min1 ≤ j ≤ kMi, wj.
You may only ask Hongcow at most 20 questions — he thinks you only need that many questions answered.
When you are ready to answer, print out a single integer - 1 on its own line, then n integers on the next line. The i-th integer should be the minimum value in the i-th row of the matrix, excluding the i-th element. Do not forget to flush the final answer as well. Printing the answer does not count as asking a question.
You will get Wrong Answer verdict if
* Your question or answers are not in the format described in this statement.
* You ask strictly more than 20 questions.
* Your question contains duplicate indices.
* The value of k in your question does not lie in the range from 1 to n, inclusive.
* Your final answer is not correct.
You will get Idleness Limit Exceeded if you don't print anything or if you forget to flush the output, including for the final answer (more info about flushing output below).
Input
The first line of input will contain a single integer n (2 ≤ n ≤ 1, 000).
Output
To print the final answer, print out the string -1 on its own line. Then, the next line should contain n integers. The i-th integer should be the minimum value of the i-th row of the matrix, excluding elements on the diagonal. Do not forget to flush your answer!
Interaction
To ask a question, print out a single integer k on its own line, denoting the size of your subset. Then, the next line should contain k integers w1, w2, ... wk. Note, you must flush your output to get a response.
Hongcow will respond by printing out a line with n integers. The i-th integer in this line represents the minimum value of Mi, wj where j is between 1 and k.
You may only ask a question at most 20 times, otherwise, you will get Wrong Answer.
To flush you can use (just after printing an integer and end-of-line):
* fflush(stdout) in C++;
* System.out.flush() in Java;
* stdout.flush() in Python;
* flush(output) in Pascal;
* See the documentation for other languages.
Hacking To hack someone, use the following format
n
M_{1,1} M_{1,2} ... M_{1,n}
M_{2,1} M_{2,2} ... M_{2,n}
...
M_{n,1} M_{n,2} ... M_{n,n}
Of course, contestant programs will not be able to see this input.
Examples
Input
3
0 0 0
2 7 0
0 0 4
3 0 8
0 5 4
Output
3
1 2 3
1
3
2
1 2
1
2
1
1
-1
2 5 4
Input
2
0 0
0 0
Output
1
2
1
1
-1
0 0
Note
In the first sample, Hongcow has the hidden matrix
[
[0, 3, 2],
[5, 0, 7],
[4, 8 ,0],
]
Here is a more readable version demonstrating the interaction. The column on the left represents Hongcow, while the column on the right represents the contestant.
3
3
1 2 3
0 0 0
1
3
2 7 0
2
1 2
0 0 4
1
2
3 0 8
1
1
0 5 4
-1
2 5 4
For the second sample, it is possible for off-diagonal elements of the matrix to be zero.
Submitted Solution:
```
from re import *
from sys import *
def readint():
return int(input())
def readfloat():
return float(input())
def readarray(N, foo=input):
return [foo() for i in range(N)]
def readlinearray(foo=int):
return list(map(foo, input().split()))
def NOD(a, b):
while b:
a,b = b, a%b
return a
def gen_primes(max):
primes = [1]*(max+1)
for i in range(2, max+1):
if primes[i]:
for j in range(i+i, max+1, i):
primes[j] = 0
primes[0] = 0
return [x for x in range(max+1) if primes[x]]
def is_prime(N):
i = 3
if not(N % 2):
return 0
while i*i < N:
if not(N % i):
return 0
i += 3
return 1
n = readint()
data = [10**9 for i in range(n)]
bits = 0
while 1 << bits < n:
bits += 1
for b in range(bits):
question = set([i + 1 for i in range(n) if (i & 1 << b)])
stdout.write('%d\n%s\n' % (len(question), ' '.join(map(str, question)), ))
stdout.flush()
answer = readlinearray()
for i in range(n):
if i + 1 not in question:
data[i] = min(data[i], answer[i])
question = set([i + 1 for i in range(n) if not(i & 1 << b)])
stdout.write('%d\n%s\n' % (len(question), ' '.join(map(str, question)), ))
stdout.flush()
answer = readlinearray()
for i in range(n):
if i + 1 not in question:
data[i] = min(data[i], answer[i])
stdout.write('-1\n%s\n' % (' '.join(map(str, data)), ))
stdout.flush()
```
|
instruction
| 0
| 8,058
| 11
| 16,116
|
Yes
|
output
| 1
| 8,058
| 11
| 16,117
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
This is an interactive problem. In the interaction section below you will see the information about flushing the output.
In this problem, you will be playing a game with Hongcow. How lucky of you!
Hongcow has a hidden n by n matrix M. Let Mi, j denote the entry i-th row and j-th column of the matrix. The rows and columns are labeled from 1 to n.
The matrix entries are between 0 and 109. In addition, Mi, i = 0 for all valid i. Your task is to find the minimum value along each row, excluding diagonal elements. Formally, for each i, you must find <image>.
To do this, you can ask Hongcow some questions.
A question consists of giving Hongcow a subset of distinct indices {w1, w2, ..., wk}, with 1 ≤ k ≤ n. Hongcow will respond with n integers. The i-th integer will contain the minimum value of min1 ≤ j ≤ kMi, wj.
You may only ask Hongcow at most 20 questions — he thinks you only need that many questions answered.
When you are ready to answer, print out a single integer - 1 on its own line, then n integers on the next line. The i-th integer should be the minimum value in the i-th row of the matrix, excluding the i-th element. Do not forget to flush the final answer as well. Printing the answer does not count as asking a question.
You will get Wrong Answer verdict if
* Your question or answers are not in the format described in this statement.
* You ask strictly more than 20 questions.
* Your question contains duplicate indices.
* The value of k in your question does not lie in the range from 1 to n, inclusive.
* Your final answer is not correct.
You will get Idleness Limit Exceeded if you don't print anything or if you forget to flush the output, including for the final answer (more info about flushing output below).
Input
The first line of input will contain a single integer n (2 ≤ n ≤ 1, 000).
Output
To print the final answer, print out the string -1 on its own line. Then, the next line should contain n integers. The i-th integer should be the minimum value of the i-th row of the matrix, excluding elements on the diagonal. Do not forget to flush your answer!
Interaction
To ask a question, print out a single integer k on its own line, denoting the size of your subset. Then, the next line should contain k integers w1, w2, ... wk. Note, you must flush your output to get a response.
Hongcow will respond by printing out a line with n integers. The i-th integer in this line represents the minimum value of Mi, wj where j is between 1 and k.
You may only ask a question at most 20 times, otherwise, you will get Wrong Answer.
To flush you can use (just after printing an integer and end-of-line):
* fflush(stdout) in C++;
* System.out.flush() in Java;
* stdout.flush() in Python;
* flush(output) in Pascal;
* See the documentation for other languages.
Hacking To hack someone, use the following format
n
M_{1,1} M_{1,2} ... M_{1,n}
M_{2,1} M_{2,2} ... M_{2,n}
...
M_{n,1} M_{n,2} ... M_{n,n}
Of course, contestant programs will not be able to see this input.
Examples
Input
3
0 0 0
2 7 0
0 0 4
3 0 8
0 5 4
Output
3
1 2 3
1
3
2
1 2
1
2
1
1
-1
2 5 4
Input
2
0 0
0 0
Output
1
2
1
1
-1
0 0
Note
In the first sample, Hongcow has the hidden matrix
[
[0, 3, 2],
[5, 0, 7],
[4, 8 ,0],
]
Here is a more readable version demonstrating the interaction. The column on the left represents Hongcow, while the column on the right represents the contestant.
3
3
1 2 3
0 0 0
1
3
2 7 0
2
1 2
0 0 4
1
2
3 0 8
1
1
0 5 4
-1
2 5 4
For the second sample, it is possible for off-diagonal elements of the matrix to be zero.
Submitted Solution:
```
n = int(input().strip())
import math
import sys
factor = 1
each_row_min = [10000000000]*n
for i in range(int(math.log(n, 2))+1):
mask = []
comp_mask = []
for j in range(n):
if (j//factor)%2 == 0:
mask.append(j)
else:
comp_mask.append(j)
print(len(mask))
print(' '.join([str(x+1) for x in mask]))
sys.stdout.flush()
results = [int(x) for x in input().split()]
for row, rowmin in enumerate(results):
if row not in mask:
each_row_min[row] = min(each_row_min[row], rowmin)
#comp
mask = comp_mask
print(len(mask))
print(' '.join([str(x+1) for x in mask]))
sys.stdout.flush()
results = [int(x) for x in input().split()]
for row, rowmin in enumerate(results):
if row not in mask:
each_row_min[row] = min(each_row_min[row], rowmin)
factor*=2
print(-1)
print(' '.join(str(x) for x in each_row_min))
sys.stdout.flush
```
|
instruction
| 0
| 8,059
| 11
| 16,118
|
No
|
output
| 1
| 8,059
| 11
| 16,119
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
This is an interactive problem. In the interaction section below you will see the information about flushing the output.
In this problem, you will be playing a game with Hongcow. How lucky of you!
Hongcow has a hidden n by n matrix M. Let Mi, j denote the entry i-th row and j-th column of the matrix. The rows and columns are labeled from 1 to n.
The matrix entries are between 0 and 109. In addition, Mi, i = 0 for all valid i. Your task is to find the minimum value along each row, excluding diagonal elements. Formally, for each i, you must find <image>.
To do this, you can ask Hongcow some questions.
A question consists of giving Hongcow a subset of distinct indices {w1, w2, ..., wk}, with 1 ≤ k ≤ n. Hongcow will respond with n integers. The i-th integer will contain the minimum value of min1 ≤ j ≤ kMi, wj.
You may only ask Hongcow at most 20 questions — he thinks you only need that many questions answered.
When you are ready to answer, print out a single integer - 1 on its own line, then n integers on the next line. The i-th integer should be the minimum value in the i-th row of the matrix, excluding the i-th element. Do not forget to flush the final answer as well. Printing the answer does not count as asking a question.
You will get Wrong Answer verdict if
* Your question or answers are not in the format described in this statement.
* You ask strictly more than 20 questions.
* Your question contains duplicate indices.
* The value of k in your question does not lie in the range from 1 to n, inclusive.
* Your final answer is not correct.
You will get Idleness Limit Exceeded if you don't print anything or if you forget to flush the output, including for the final answer (more info about flushing output below).
Input
The first line of input will contain a single integer n (2 ≤ n ≤ 1, 000).
Output
To print the final answer, print out the string -1 on its own line. Then, the next line should contain n integers. The i-th integer should be the minimum value of the i-th row of the matrix, excluding elements on the diagonal. Do not forget to flush your answer!
Interaction
To ask a question, print out a single integer k on its own line, denoting the size of your subset. Then, the next line should contain k integers w1, w2, ... wk. Note, you must flush your output to get a response.
Hongcow will respond by printing out a line with n integers. The i-th integer in this line represents the minimum value of Mi, wj where j is between 1 and k.
You may only ask a question at most 20 times, otherwise, you will get Wrong Answer.
To flush you can use (just after printing an integer and end-of-line):
* fflush(stdout) in C++;
* System.out.flush() in Java;
* stdout.flush() in Python;
* flush(output) in Pascal;
* See the documentation for other languages.
Hacking To hack someone, use the following format
n
M_{1,1} M_{1,2} ... M_{1,n}
M_{2,1} M_{2,2} ... M_{2,n}
...
M_{n,1} M_{n,2} ... M_{n,n}
Of course, contestant programs will not be able to see this input.
Examples
Input
3
0 0 0
2 7 0
0 0 4
3 0 8
0 5 4
Output
3
1 2 3
1
3
2
1 2
1
2
1
1
-1
2 5 4
Input
2
0 0
0 0
Output
1
2
1
1
-1
0 0
Note
In the first sample, Hongcow has the hidden matrix
[
[0, 3, 2],
[5, 0, 7],
[4, 8 ,0],
]
Here is a more readable version demonstrating the interaction. The column on the left represents Hongcow, while the column on the right represents the contestant.
3
3
1 2 3
0 0 0
1
3
2 7 0
2
1 2
0 0 4
1
2
3 0 8
1
1
0 5 4
-1
2 5 4
For the second sample, it is possible for off-diagonal elements of the matrix to be zero.
Submitted Solution:
```
from random import *
n = int(input())
res = [10 ** 10] * (n + 1)
my = [i for i in range(1, n + 1)]
for i in range(20):
shuffle(my)
num = n // 2
ask = my[:num]
print(num)
print(' '.join(map(str, ask)))
ans = list(map(int, input().split()))
for i in range(1, n + 1):
if i not in ask:
res[i] = min(res[i], ans[i - 1])
print(-1)
print(' '.join(map(str, res[1:])))
```
|
instruction
| 0
| 8,060
| 11
| 16,120
|
No
|
output
| 1
| 8,060
| 11
| 16,121
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
This is an interactive problem. In the interaction section below you will see the information about flushing the output.
In this problem, you will be playing a game with Hongcow. How lucky of you!
Hongcow has a hidden n by n matrix M. Let Mi, j denote the entry i-th row and j-th column of the matrix. The rows and columns are labeled from 1 to n.
The matrix entries are between 0 and 109. In addition, Mi, i = 0 for all valid i. Your task is to find the minimum value along each row, excluding diagonal elements. Formally, for each i, you must find <image>.
To do this, you can ask Hongcow some questions.
A question consists of giving Hongcow a subset of distinct indices {w1, w2, ..., wk}, with 1 ≤ k ≤ n. Hongcow will respond with n integers. The i-th integer will contain the minimum value of min1 ≤ j ≤ kMi, wj.
You may only ask Hongcow at most 20 questions — he thinks you only need that many questions answered.
When you are ready to answer, print out a single integer - 1 on its own line, then n integers on the next line. The i-th integer should be the minimum value in the i-th row of the matrix, excluding the i-th element. Do not forget to flush the final answer as well. Printing the answer does not count as asking a question.
You will get Wrong Answer verdict if
* Your question or answers are not in the format described in this statement.
* You ask strictly more than 20 questions.
* Your question contains duplicate indices.
* The value of k in your question does not lie in the range from 1 to n, inclusive.
* Your final answer is not correct.
You will get Idleness Limit Exceeded if you don't print anything or if you forget to flush the output, including for the final answer (more info about flushing output below).
Input
The first line of input will contain a single integer n (2 ≤ n ≤ 1, 000).
Output
To print the final answer, print out the string -1 on its own line. Then, the next line should contain n integers. The i-th integer should be the minimum value of the i-th row of the matrix, excluding elements on the diagonal. Do not forget to flush your answer!
Interaction
To ask a question, print out a single integer k on its own line, denoting the size of your subset. Then, the next line should contain k integers w1, w2, ... wk. Note, you must flush your output to get a response.
Hongcow will respond by printing out a line with n integers. The i-th integer in this line represents the minimum value of Mi, wj where j is between 1 and k.
You may only ask a question at most 20 times, otherwise, you will get Wrong Answer.
To flush you can use (just after printing an integer and end-of-line):
* fflush(stdout) in C++;
* System.out.flush() in Java;
* stdout.flush() in Python;
* flush(output) in Pascal;
* See the documentation for other languages.
Hacking To hack someone, use the following format
n
M_{1,1} M_{1,2} ... M_{1,n}
M_{2,1} M_{2,2} ... M_{2,n}
...
M_{n,1} M_{n,2} ... M_{n,n}
Of course, contestant programs will not be able to see this input.
Examples
Input
3
0 0 0
2 7 0
0 0 4
3 0 8
0 5 4
Output
3
1 2 3
1
3
2
1 2
1
2
1
1
-1
2 5 4
Input
2
0 0
0 0
Output
1
2
1
1
-1
0 0
Note
In the first sample, Hongcow has the hidden matrix
[
[0, 3, 2],
[5, 0, 7],
[4, 8 ,0],
]
Here is a more readable version demonstrating the interaction. The column on the left represents Hongcow, while the column on the right represents the contestant.
3
3
1 2 3
0 0 0
1
3
2 7 0
2
1 2
0 0 4
1
2
3 0 8
1
1
0 5 4
-1
2 5 4
For the second sample, it is possible for off-diagonal elements of the matrix to be zero.
Submitted Solution:
```
import sys
def f(x,y):
if not x: return y
elif not y: return x
else: return min(x,y)
count = 0
n = int(input())
mask = 1
res = [0] * n
while mask <= n:
a = list(map(str, filter(lambda x: (x & mask) == 0, range(1, n+1))))
if a:
print(len(a))
print(" ".join(a))
sys.stdout.flush()
current = map(int, input().split())
res = list(map(f, res, current))
count += 1
if count == 20: break
a = list(map(str, filter(lambda x: x & mask, range(1, n+1))))
if a:
print(len(a))
print(" ".join(a))
sys.stdout.flush()
current = map(int, input().split())
res = list(map(f, res, current))
count += 1
if count == 20: break
mask <<= 1
print(-1)
print(" ".join(map(str, res)))
sys.stdout.flush()
```
|
instruction
| 0
| 8,061
| 11
| 16,122
|
No
|
output
| 1
| 8,061
| 11
| 16,123
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
This is an interactive problem. In the interaction section below you will see the information about flushing the output.
In this problem, you will be playing a game with Hongcow. How lucky of you!
Hongcow has a hidden n by n matrix M. Let Mi, j denote the entry i-th row and j-th column of the matrix. The rows and columns are labeled from 1 to n.
The matrix entries are between 0 and 109. In addition, Mi, i = 0 for all valid i. Your task is to find the minimum value along each row, excluding diagonal elements. Formally, for each i, you must find <image>.
To do this, you can ask Hongcow some questions.
A question consists of giving Hongcow a subset of distinct indices {w1, w2, ..., wk}, with 1 ≤ k ≤ n. Hongcow will respond with n integers. The i-th integer will contain the minimum value of min1 ≤ j ≤ kMi, wj.
You may only ask Hongcow at most 20 questions — he thinks you only need that many questions answered.
When you are ready to answer, print out a single integer - 1 on its own line, then n integers on the next line. The i-th integer should be the minimum value in the i-th row of the matrix, excluding the i-th element. Do not forget to flush the final answer as well. Printing the answer does not count as asking a question.
You will get Wrong Answer verdict if
* Your question or answers are not in the format described in this statement.
* You ask strictly more than 20 questions.
* Your question contains duplicate indices.
* The value of k in your question does not lie in the range from 1 to n, inclusive.
* Your final answer is not correct.
You will get Idleness Limit Exceeded if you don't print anything or if you forget to flush the output, including for the final answer (more info about flushing output below).
Input
The first line of input will contain a single integer n (2 ≤ n ≤ 1, 000).
Output
To print the final answer, print out the string -1 on its own line. Then, the next line should contain n integers. The i-th integer should be the minimum value of the i-th row of the matrix, excluding elements on the diagonal. Do not forget to flush your answer!
Interaction
To ask a question, print out a single integer k on its own line, denoting the size of your subset. Then, the next line should contain k integers w1, w2, ... wk. Note, you must flush your output to get a response.
Hongcow will respond by printing out a line with n integers. The i-th integer in this line represents the minimum value of Mi, wj where j is between 1 and k.
You may only ask a question at most 20 times, otherwise, you will get Wrong Answer.
To flush you can use (just after printing an integer and end-of-line):
* fflush(stdout) in C++;
* System.out.flush() in Java;
* stdout.flush() in Python;
* flush(output) in Pascal;
* See the documentation for other languages.
Hacking To hack someone, use the following format
n
M_{1,1} M_{1,2} ... M_{1,n}
M_{2,1} M_{2,2} ... M_{2,n}
...
M_{n,1} M_{n,2} ... M_{n,n}
Of course, contestant programs will not be able to see this input.
Examples
Input
3
0 0 0
2 7 0
0 0 4
3 0 8
0 5 4
Output
3
1 2 3
1
3
2
1 2
1
2
1
1
-1
2 5 4
Input
2
0 0
0 0
Output
1
2
1
1
-1
0 0
Note
In the first sample, Hongcow has the hidden matrix
[
[0, 3, 2],
[5, 0, 7],
[4, 8 ,0],
]
Here is a more readable version demonstrating the interaction. The column on the left represents Hongcow, while the column on the right represents the contestant.
3
3
1 2 3
0 0 0
1
3
2 7 0
2
1 2
0 0 4
1
2
3 0 8
1
1
0 5 4
-1
2 5 4
For the second sample, it is possible for off-diagonal elements of the matrix to be zero.
Submitted Solution:
```
import sys
def f(x,y):
if not x: return y
elif not y: return x
else: return min(x,y)
n = int(input())
mask = 1
res = [0] * n
while mask <= n:
a = list(map(str, filter(lambda x: (x & mask) == 0, range(1, n+1))))
if a:
print(len(a))
print(" ".join(a))
sys.stdout.flush()
current = map(int, input().split())
res = list(map(f, res, current))
a = list(map(str, filter(lambda x: x & mask, range(1, n+1))))
if a:
print(len(a))
print(" ".join(a))
sys.stdout.flush()
current = map(int, input().split())
res = list(map(f, res, current))
mask <<= 1
print(-1)
print(" ".join(map(str, res)))
sys.stdout.flush()
```
|
instruction
| 0
| 8,062
| 11
| 16,124
|
No
|
output
| 1
| 8,062
| 11
| 16,125
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In this problem, you should process T testcases.
For each testcase, you are given four integers N, M, A, B.
Calculate \sum_{i = 0}^{N - 1} floor((A \times i + B) / M).
Constraints
* 1 \leq T \leq 100,000
* 1 \leq N, M \leq 10^9
* 0 \leq A, B < M
Input
Input is given from Standard Input in the following format:
T
N_0 M_0 A_0 B_0
N_1 M_1 A_1 B_1
:
N_{T - 1} M_{T - 1} A_{T - 1} B_{T - 1}
Output
Print the answer for each testcase.
Example
Input
5
4 10 6 3
6 5 4 3
1 1 0 0
31415 92653 58979 32384
1000000000 1000000000 999999999 999999999
Output
3
13
0
314095480
499999999500000000
Submitted Solution:
```
# 一番早いのを写経したものを弄ってアルゴリズム勉強のための試し打ち中
def floor_sum(n, m, a, b):
res = 0
if b >= m:
res += n * (b // m)
b %= m
while True:
if a >= m:
res += (n - 1) * n * (a // m) // 2
a %= m
y_max = (a * n + b) // m
if y_max == 0: break
x_max = b - y_max * m
res += (n + x_max // a) * y_max
n, m, a, b = y_max, a, m, x_max % a
return res
import sys
input = sys.stdin.buffer.readline
T = int(input())
res = [''] * T
for i in range(T):
n, m, a, b = map(int, input().split())
res[i] = str(floor_sum(n, m, a, b))
print('\n'.join(res))
```
|
instruction
| 0
| 8,176
| 11
| 16,352
|
Yes
|
output
| 1
| 8,176
| 11
| 16,353
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In this problem, you should process T testcases.
For each testcase, you are given four integers N, M, A, B.
Calculate \sum_{i = 0}^{N - 1} floor((A \times i + B) / M).
Constraints
* 1 \leq T \leq 100,000
* 1 \leq N, M \leq 10^9
* 0 \leq A, B < M
Input
Input is given from Standard Input in the following format:
T
N_0 M_0 A_0 B_0
N_1 M_1 A_1 B_1
:
N_{T - 1} M_{T - 1} A_{T - 1} B_{T - 1}
Output
Print the answer for each testcase.
Example
Input
5
4 10 6 3
6 5 4 3
1 1 0 0
31415 92653 58979 32384
1000000000 1000000000 999999999 999999999
Output
3
13
0
314095480
499999999500000000
Submitted Solution:
```
# 一番早いのを写経したものを弄ってアルゴリズム勉強のための試し打ち中
def floor_sum(n, m, a, b):
res = 0
if b >= m:
res += n * (b // m)
b %= m
while True:
if a >= m:
res += (n - 1) * n * (a // m) // 2
a %= m
y_max = a*n//m
if y_max == 0: break
x_max = -y_max*m
res += (n + x_max // a) * y_max
n, m, a, b = y_max, a, m, x_max % a
return res
import sys
input = sys.stdin.buffer.readline
T = int(input())
res = [''] * T
for i in range(T):
n, m, a, b = map(int, input().split())
res[i] = str(floor_sum(n, m, a, b))
print('\n'.join(res))
```
|
instruction
| 0
| 8,180
| 11
| 16,360
|
No
|
output
| 1
| 8,180
| 11
| 16,361
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens.
There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i.
According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction.
* The absolute difference of their attendee numbers is equal to the sum of their heights.
There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above?
P.S.: We cannot let you know the secret.
Constraints
* All values in input are integers.
* 2 \leq N \leq 2 \times 10^5
* 1 \leq A_i \leq 10^9\ (1 \leq i \leq N)
Input
Input is given from Standard Input in the following format:
N
A_1 A_2 \dots A_N
Output
Print the number of pairs satisfying the condition.
Examples
Input
6
2 3 3 1 3 1
Output
3
Input
6
5 2 4 2 8 8
Output
0
Input
32
3 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 6 2 6 4 3 3 8 3 2 7 9 5
Output
22
Submitted Solution:
```
n = int(input())
a = list(map(int, input().split()))
b = [0] * n
count = 0
for i in range(n):
if i + a[i] < n:
b[i + a[i]] += 1
if i - a[i] >= 0:
count += b[i-a[i]]
print(count)
```
|
instruction
| 0
| 8,192
| 11
| 16,384
|
Yes
|
output
| 1
| 8,192
| 11
| 16,385
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens.
There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i.
According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction.
* The absolute difference of their attendee numbers is equal to the sum of their heights.
There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above?
P.S.: We cannot let you know the secret.
Constraints
* All values in input are integers.
* 2 \leq N \leq 2 \times 10^5
* 1 \leq A_i \leq 10^9\ (1 \leq i \leq N)
Input
Input is given from Standard Input in the following format:
N
A_1 A_2 \dots A_N
Output
Print the number of pairs satisfying the condition.
Examples
Input
6
2 3 3 1 3 1
Output
3
Input
6
5 2 4 2 8 8
Output
0
Input
32
3 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 6 2 6 4 3 3 8 3 2 7 9 5
Output
22
Submitted Solution:
```
_,*l=map(int,open(0).read().split());d,a,i={},0,0
for h in l:d[i+h]=d.get(i+h,0)+1;a+=d.get(i-h,0);i+=1
print(a)
```
|
instruction
| 0
| 8,193
| 11
| 16,386
|
Yes
|
output
| 1
| 8,193
| 11
| 16,387
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens.
There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i.
According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction.
* The absolute difference of their attendee numbers is equal to the sum of their heights.
There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above?
P.S.: We cannot let you know the secret.
Constraints
* All values in input are integers.
* 2 \leq N \leq 2 \times 10^5
* 1 \leq A_i \leq 10^9\ (1 \leq i \leq N)
Input
Input is given from Standard Input in the following format:
N
A_1 A_2 \dots A_N
Output
Print the number of pairs satisfying the condition.
Examples
Input
6
2 3 3 1 3 1
Output
3
Input
6
5 2 4 2 8 8
Output
0
Input
32
3 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 6 2 6 4 3 3 8 3 2 7 9 5
Output
22
Submitted Solution:
```
n=int(input())
l=list(map(int,input().split()))
an=0;d={}
for i in range(n):
d[l[i]+i]=d.get(l[i]+i,0)+1
an+=d.get(i-l[i],0)
print(an)
```
|
instruction
| 0
| 8,194
| 11
| 16,388
|
Yes
|
output
| 1
| 8,194
| 11
| 16,389
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens.
There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i.
According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction.
* The absolute difference of their attendee numbers is equal to the sum of their heights.
There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above?
P.S.: We cannot let you know the secret.
Constraints
* All values in input are integers.
* 2 \leq N \leq 2 \times 10^5
* 1 \leq A_i \leq 10^9\ (1 \leq i \leq N)
Input
Input is given from Standard Input in the following format:
N
A_1 A_2 \dots A_N
Output
Print the number of pairs satisfying the condition.
Examples
Input
6
2 3 3 1 3 1
Output
3
Input
6
5 2 4 2 8 8
Output
0
Input
32
3 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 6 2 6 4 3 3 8 3 2 7 9 5
Output
22
Submitted Solution:
```
import collections
n=int(input())
a=list(map(int,input().split()))
memo=collections.defaultdict(int)
ans=0
for i,x in enumerate(a,1):
ans+=memo[i-x]
memo[i+x]+=1
print(ans)
```
|
instruction
| 0
| 8,195
| 11
| 16,390
|
Yes
|
output
| 1
| 8,195
| 11
| 16,391
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens.
There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i.
According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction.
* The absolute difference of their attendee numbers is equal to the sum of their heights.
There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above?
P.S.: We cannot let you know the secret.
Constraints
* All values in input are integers.
* 2 \leq N \leq 2 \times 10^5
* 1 \leq A_i \leq 10^9\ (1 \leq i \leq N)
Input
Input is given from Standard Input in the following format:
N
A_1 A_2 \dots A_N
Output
Print the number of pairs satisfying the condition.
Examples
Input
6
2 3 3 1 3 1
Output
3
Input
6
5 2 4 2 8 8
Output
0
Input
32
3 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 6 2 6 4 3 3 8 3 2 7 9 5
Output
22
Submitted Solution:
```
n = int(input())
a = list(map(int, input().split()))
s = 0
for i in range(n):
for j in range(i + 1, n):
ndif = abs(i - j)
tsum = a[i] + a[j]
if ndif == tsum:
s += 1
print(s)
```
|
instruction
| 0
| 8,196
| 11
| 16,392
|
No
|
output
| 1
| 8,196
| 11
| 16,393
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens.
There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i.
According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction.
* The absolute difference of their attendee numbers is equal to the sum of their heights.
There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above?
P.S.: We cannot let you know the secret.
Constraints
* All values in input are integers.
* 2 \leq N \leq 2 \times 10^5
* 1 \leq A_i \leq 10^9\ (1 \leq i \leq N)
Input
Input is given from Standard Input in the following format:
N
A_1 A_2 \dots A_N
Output
Print the number of pairs satisfying the condition.
Examples
Input
6
2 3 3 1 3 1
Output
3
Input
6
5 2 4 2 8 8
Output
0
Input
32
3 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 6 2 6 4 3 3 8 3 2 7 9 5
Output
22
Submitted Solution:
```
import collections
N = int(input())
A = list(map(int, input().split()))
L = [i + A[i] for i in range(N)]
R = [i - A[i] for i in range(N)]
countL = collections.Counter(L)
countR = collections.Counter(R)
print([countL[n] * countR[n] for n in countL.keys()])
```
|
instruction
| 0
| 8,197
| 11
| 16,394
|
No
|
output
| 1
| 8,197
| 11
| 16,395
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens.
There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i.
According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction.
* The absolute difference of their attendee numbers is equal to the sum of their heights.
There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above?
P.S.: We cannot let you know the secret.
Constraints
* All values in input are integers.
* 2 \leq N \leq 2 \times 10^5
* 1 \leq A_i \leq 10^9\ (1 \leq i \leq N)
Input
Input is given from Standard Input in the following format:
N
A_1 A_2 \dots A_N
Output
Print the number of pairs satisfying the condition.
Examples
Input
6
2 3 3 1 3 1
Output
3
Input
6
5 2 4 2 8 8
Output
0
Input
32
3 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 6 2 6 4 3 3 8 3 2 7 9 5
Output
22
Submitted Solution:
```
N = int(input())
A = list(map(int,input().split()))
ans = 0
for i in range(100):
for j in range(i+1,N):
if A[i]+A[j] == j-i:
ans += 1
for i in range(100,N,16):
for j in range(i+1,N):
if A[i]+A[j] == j-i:
ans += 1
for i in range(100,N,37):
for j in range(i+1,N):
if A[i]+A[j] == j-i:
ans += 1
for i in range(100,N,41):
for j in range(i+1,N):
if A[i]+A[j] == j-i:
ans += 1
print(ans)
```
|
instruction
| 0
| 8,199
| 11
| 16,398
|
No
|
output
| 1
| 8,199
| 11
| 16,399
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.