output_description
stringlengths 15
956
| submission_id
stringlengths 10
10
| status
stringclasses 3
values | problem_id
stringlengths 6
6
| input_description
stringlengths 9
2.55k
| attempt
stringlengths 1
13.7k
| problem_description
stringlengths 7
5.24k
| samples
stringlengths 2
2.72k
|
---|---|---|---|---|---|---|---|
Print the maximum number of candies that can be collected.
* * *
|
s596681501
|
Accepted
|
p03449
|
Input is given from Standard Input in the following format:
N
A_{1, 1} A_{1, 2} ... A_{1, N}
A_{2, 1} A_{2, 2} ... A_{2, N}
|
# print#!/usr/bin/env python3
# %% for atcoder uniittest use
import sys
input = lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):
return map(type, input().split())
def tupin(t=int):
return tuple(pin(t))
def lispin(t=int):
return list(pin(t))
# %%code
from itertools import accumulate
def resolve():
(N,) = pin()
A1 = lispin()
A2 = lispin()
B1 = list(accumulate(A1))
B2 = list(accumulate(A2))
ans = B1[0] + B2[-1]
for i in range(1, N):
ans = max(ans, B1[i] + B2[-1] - B2[i - 1])
print(ans)
# %%submit!
resolve()
|
Statement
We have a 2 \times N grid. We will denote the square at the i-th row and j-th
column (1 \leq i \leq 2, 1 \leq j \leq N) as (i, j).
You are initially in the top-left square, (1, 1). You will travel to the
bottom-right square, (2, N), by repeatedly moving right or down.
The square (i, j) contains A_{i, j} candies. You will collect all the candies
you visit during the travel. The top-left and bottom-right squares also
contain candies, and you will also collect them.
At most how many candies can you collect when you choose the best way to
travel?
|
[{"input": "5\n 3 2 2 4 1\n 1 2 2 2 1", "output": "14\n \n\nThe number of collected candies will be maximized when you:\n\n * move right three times, then move down once, then move right once.\n\n* * *"}, {"input": "4\n 1 1 1 1\n 1 1 1 1", "output": "5\n \n\nYou will always collect the same number of candies, regardless of how you\ntravel.\n\n* * *"}, {"input": "7\n 3 3 4 5 4 5 3\n 5 3 4 4 2 3 2", "output": "29\n \n\n* * *"}, {"input": "1\n 2\n 3", "output": "5"}]
|
Print the maximum number of candies that can be collected.
* * *
|
s818561778
|
Accepted
|
p03449
|
Input is given from Standard Input in the following format:
N
A_{1, 1} A_{1, 2} ... A_{1, N}
A_{2, 1} A_{2, 2} ... A_{2, N}
|
n, a, b = int(input()), list(map(int, input().split())), list(map(int, input().split()))
print(max([sum(a[0 : i + 1] + b[i:]) for i in range(0, n)]))
|
Statement
We have a 2 \times N grid. We will denote the square at the i-th row and j-th
column (1 \leq i \leq 2, 1 \leq j \leq N) as (i, j).
You are initially in the top-left square, (1, 1). You will travel to the
bottom-right square, (2, N), by repeatedly moving right or down.
The square (i, j) contains A_{i, j} candies. You will collect all the candies
you visit during the travel. The top-left and bottom-right squares also
contain candies, and you will also collect them.
At most how many candies can you collect when you choose the best way to
travel?
|
[{"input": "5\n 3 2 2 4 1\n 1 2 2 2 1", "output": "14\n \n\nThe number of collected candies will be maximized when you:\n\n * move right three times, then move down once, then move right once.\n\n* * *"}, {"input": "4\n 1 1 1 1\n 1 1 1 1", "output": "5\n \n\nYou will always collect the same number of candies, regardless of how you\ntravel.\n\n* * *"}, {"input": "7\n 3 3 4 5 4 5 3\n 5 3 4 4 2 3 2", "output": "29\n \n\n* * *"}, {"input": "1\n 2\n 3", "output": "5"}]
|
Print the maximum number of candies that can be collected.
* * *
|
s451702661
|
Runtime Error
|
p03449
|
Input is given from Standard Input in the following format:
N
A_{1, 1} A_{1, 2} ... A_{1, N}
A_{2, 1} A_{2, 2} ... A_{2, N}
|
N = int(input())
candies_i = list(map(int, input().split()))
candies_j = list(map(int, input().split()))
l = []
for i range(N):
total_li = sum(candies_i[:i])
total_lj = sum(candies_j[i:])
total = ( total_li + total_lj )
l.append(total)
print(max(l))
|
Statement
We have a 2 \times N grid. We will denote the square at the i-th row and j-th
column (1 \leq i \leq 2, 1 \leq j \leq N) as (i, j).
You are initially in the top-left square, (1, 1). You will travel to the
bottom-right square, (2, N), by repeatedly moving right or down.
The square (i, j) contains A_{i, j} candies. You will collect all the candies
you visit during the travel. The top-left and bottom-right squares also
contain candies, and you will also collect them.
At most how many candies can you collect when you choose the best way to
travel?
|
[{"input": "5\n 3 2 2 4 1\n 1 2 2 2 1", "output": "14\n \n\nThe number of collected candies will be maximized when you:\n\n * move right three times, then move down once, then move right once.\n\n* * *"}, {"input": "4\n 1 1 1 1\n 1 1 1 1", "output": "5\n \n\nYou will always collect the same number of candies, regardless of how you\ntravel.\n\n* * *"}, {"input": "7\n 3 3 4 5 4 5 3\n 5 3 4 4 2 3 2", "output": "29\n \n\n* * *"}, {"input": "1\n 2\n 3", "output": "5"}]
|
Print the maximum number of candies that can be collected.
* * *
|
s344351427
|
Runtime Error
|
p03449
|
Input is given from Standard Input in the following format:
N
A_{1, 1} A_{1, 2} ... A_{1, N}
A_{2, 1} A_{2, 2} ... A_{2, N}
|
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
list1 = []
ame = A[0]
for i in range(N-1):
list1.append(sum(A[:i+1])+sum(B[i:]))
if list1 = []:
print(A[0]+b[0])
else:
print(max(list1))
|
Statement
We have a 2 \times N grid. We will denote the square at the i-th row and j-th
column (1 \leq i \leq 2, 1 \leq j \leq N) as (i, j).
You are initially in the top-left square, (1, 1). You will travel to the
bottom-right square, (2, N), by repeatedly moving right or down.
The square (i, j) contains A_{i, j} candies. You will collect all the candies
you visit during the travel. The top-left and bottom-right squares also
contain candies, and you will also collect them.
At most how many candies can you collect when you choose the best way to
travel?
|
[{"input": "5\n 3 2 2 4 1\n 1 2 2 2 1", "output": "14\n \n\nThe number of collected candies will be maximized when you:\n\n * move right three times, then move down once, then move right once.\n\n* * *"}, {"input": "4\n 1 1 1 1\n 1 1 1 1", "output": "5\n \n\nYou will always collect the same number of candies, regardless of how you\ntravel.\n\n* * *"}, {"input": "7\n 3 3 4 5 4 5 3\n 5 3 4 4 2 3 2", "output": "29\n \n\n* * *"}, {"input": "1\n 2\n 3", "output": "5"}]
|
Print the maximum number of candies that can be collected.
* * *
|
s523248122
|
Runtime Error
|
p03449
|
Input is given from Standard Input in the following format:
N
A_{1, 1} A_{1, 2} ... A_{1, N}
A_{2, 1} A_{2, 2} ... A_{2, N}
|
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
ans = []
for i in range(n):
ans.append(sum(a[0:i+1] + sum(b[i:n]))
print(max(ans))
|
Statement
We have a 2 \times N grid. We will denote the square at the i-th row and j-th
column (1 \leq i \leq 2, 1 \leq j \leq N) as (i, j).
You are initially in the top-left square, (1, 1). You will travel to the
bottom-right square, (2, N), by repeatedly moving right or down.
The square (i, j) contains A_{i, j} candies. You will collect all the candies
you visit during the travel. The top-left and bottom-right squares also
contain candies, and you will also collect them.
At most how many candies can you collect when you choose the best way to
travel?
|
[{"input": "5\n 3 2 2 4 1\n 1 2 2 2 1", "output": "14\n \n\nThe number of collected candies will be maximized when you:\n\n * move right three times, then move down once, then move right once.\n\n* * *"}, {"input": "4\n 1 1 1 1\n 1 1 1 1", "output": "5\n \n\nYou will always collect the same number of candies, regardless of how you\ntravel.\n\n* * *"}, {"input": "7\n 3 3 4 5 4 5 3\n 5 3 4 4 2 3 2", "output": "29\n \n\n* * *"}, {"input": "1\n 2\n 3", "output": "5"}]
|
Print the maximum number of candies that can be collected.
* * *
|
s555612224
|
Runtime Error
|
p03449
|
Input is given from Standard Input in the following format:
N
A_{1, 1} A_{1, 2} ... A_{1, N}
A_{2, 1} A_{2, 2} ... A_{2, N}
|
N = int(input())
candies_i = list(map(int, input().split()))
candies_j = list(map(int, input().split()))
l = []
for i in range(N):
total_li = sum(candies_i[:+=1])
total_lj = sum(candies_j[+=1:])
total = total_li + total_lj
l.append(total)
print(max(l))
|
Statement
We have a 2 \times N grid. We will denote the square at the i-th row and j-th
column (1 \leq i \leq 2, 1 \leq j \leq N) as (i, j).
You are initially in the top-left square, (1, 1). You will travel to the
bottom-right square, (2, N), by repeatedly moving right or down.
The square (i, j) contains A_{i, j} candies. You will collect all the candies
you visit during the travel. The top-left and bottom-right squares also
contain candies, and you will also collect them.
At most how many candies can you collect when you choose the best way to
travel?
|
[{"input": "5\n 3 2 2 4 1\n 1 2 2 2 1", "output": "14\n \n\nThe number of collected candies will be maximized when you:\n\n * move right three times, then move down once, then move right once.\n\n* * *"}, {"input": "4\n 1 1 1 1\n 1 1 1 1", "output": "5\n \n\nYou will always collect the same number of candies, regardless of how you\ntravel.\n\n* * *"}, {"input": "7\n 3 3 4 5 4 5 3\n 5 3 4 4 2 3 2", "output": "29\n \n\n* * *"}, {"input": "1\n 2\n 3", "output": "5"}]
|
Print the maximum number of candies that can be collected.
* * *
|
s896293907
|
Runtime Error
|
p03449
|
Input is given from Standard Input in the following format:
N
A_{1, 1} A_{1, 2} ... A_{1, N}
A_{2, 1} A_{2, 2} ... A_{2, N}
|
N = int(input())
a = [list(map(int,input().split())) for i in range(2)]
s = 0; t = 0; u = 0; v = 0
for i in range(0,N):
for j in range(0,i+1):
s += a[0][j]
t += a[1][j]
u += a[0][N-j-1]
v += a[1][N-j-1]
if s>=t and v>=u:
print(s+v)
|
Statement
We have a 2 \times N grid. We will denote the square at the i-th row and j-th
column (1 \leq i \leq 2, 1 \leq j \leq N) as (i, j).
You are initially in the top-left square, (1, 1). You will travel to the
bottom-right square, (2, N), by repeatedly moving right or down.
The square (i, j) contains A_{i, j} candies. You will collect all the candies
you visit during the travel. The top-left and bottom-right squares also
contain candies, and you will also collect them.
At most how many candies can you collect when you choose the best way to
travel?
|
[{"input": "5\n 3 2 2 4 1\n 1 2 2 2 1", "output": "14\n \n\nThe number of collected candies will be maximized when you:\n\n * move right three times, then move down once, then move right once.\n\n* * *"}, {"input": "4\n 1 1 1 1\n 1 1 1 1", "output": "5\n \n\nYou will always collect the same number of candies, regardless of how you\ntravel.\n\n* * *"}, {"input": "7\n 3 3 4 5 4 5 3\n 5 3 4 4 2 3 2", "output": "29\n \n\n* * *"}, {"input": "1\n 2\n 3", "output": "5"}]
|
Print the maximum number of candies that can be collected.
* * *
|
s476748213
|
Runtime Error
|
p03449
|
Input is given from Standard Input in the following format:
N
A_{1, 1} A_{1, 2} ... A_{1, N}
A_{2, 1} A_{2, 2} ... A_{2, N}
|
n=int(input())
a=list(map(int,input().split()))
b=list(map(int, input().split()))
ans = 0
for i in range(n):
ans = max(ans,sum(a[:i+1])+sum(b[i:n]))
|
Statement
We have a 2 \times N grid. We will denote the square at the i-th row and j-th
column (1 \leq i \leq 2, 1 \leq j \leq N) as (i, j).
You are initially in the top-left square, (1, 1). You will travel to the
bottom-right square, (2, N), by repeatedly moving right or down.
The square (i, j) contains A_{i, j} candies. You will collect all the candies
you visit during the travel. The top-left and bottom-right squares also
contain candies, and you will also collect them.
At most how many candies can you collect when you choose the best way to
travel?
|
[{"input": "5\n 3 2 2 4 1\n 1 2 2 2 1", "output": "14\n \n\nThe number of collected candies will be maximized when you:\n\n * move right three times, then move down once, then move right once.\n\n* * *"}, {"input": "4\n 1 1 1 1\n 1 1 1 1", "output": "5\n \n\nYou will always collect the same number of candies, regardless of how you\ntravel.\n\n* * *"}, {"input": "7\n 3 3 4 5 4 5 3\n 5 3 4 4 2 3 2", "output": "29\n \n\n* * *"}, {"input": "1\n 2\n 3", "output": "5"}]
|
Print the maximum number of candies that can be collected.
* * *
|
s414860173
|
Accepted
|
p03449
|
Input is given from Standard Input in the following format:
N
A_{1, 1} A_{1, 2} ... A_{1, N}
A_{2, 1} A_{2, 2} ... A_{2, N}
|
n = int(input())
r1 = tuple(int(x) for x in input().split())
r2 = tuple(int(x) for x in input().split())
# If d == 0, first it moves down, then it moves right.
candies = (sum(r1[: d + 1]) + sum(r2[d:]) for d in range(n))
print(max(candies))
|
Statement
We have a 2 \times N grid. We will denote the square at the i-th row and j-th
column (1 \leq i \leq 2, 1 \leq j \leq N) as (i, j).
You are initially in the top-left square, (1, 1). You will travel to the
bottom-right square, (2, N), by repeatedly moving right or down.
The square (i, j) contains A_{i, j} candies. You will collect all the candies
you visit during the travel. The top-left and bottom-right squares also
contain candies, and you will also collect them.
At most how many candies can you collect when you choose the best way to
travel?
|
[{"input": "5\n 3 2 2 4 1\n 1 2 2 2 1", "output": "14\n \n\nThe number of collected candies will be maximized when you:\n\n * move right three times, then move down once, then move right once.\n\n* * *"}, {"input": "4\n 1 1 1 1\n 1 1 1 1", "output": "5\n \n\nYou will always collect the same number of candies, regardless of how you\ntravel.\n\n* * *"}, {"input": "7\n 3 3 4 5 4 5 3\n 5 3 4 4 2 3 2", "output": "29\n \n\n* * *"}, {"input": "1\n 2\n 3", "output": "5"}]
|
Print the maximum number of candies that can be collected.
* * *
|
s606405259
|
Accepted
|
p03449
|
Input is given from Standard Input in the following format:
N
A_{1, 1} A_{1, 2} ... A_{1, N}
A_{2, 1} A_{2, 2} ... A_{2, N}
|
N = int(input())
A = []
for _ in range(2):
temp = list(map(int, input().strip().split()))
A.append(temp)
total = 0
for j in range(N):
row = 0
col = 0
total_temp = 0
while col < N:
if col == j:
total_temp += A[row][col]
row += 1
total_temp += A[row][col]
col += 1
if total < total_temp:
total = total_temp
print(total)
|
Statement
We have a 2 \times N grid. We will denote the square at the i-th row and j-th
column (1 \leq i \leq 2, 1 \leq j \leq N) as (i, j).
You are initially in the top-left square, (1, 1). You will travel to the
bottom-right square, (2, N), by repeatedly moving right or down.
The square (i, j) contains A_{i, j} candies. You will collect all the candies
you visit during the travel. The top-left and bottom-right squares also
contain candies, and you will also collect them.
At most how many candies can you collect when you choose the best way to
travel?
|
[{"input": "5\n 3 2 2 4 1\n 1 2 2 2 1", "output": "14\n \n\nThe number of collected candies will be maximized when you:\n\n * move right three times, then move down once, then move right once.\n\n* * *"}, {"input": "4\n 1 1 1 1\n 1 1 1 1", "output": "5\n \n\nYou will always collect the same number of candies, regardless of how you\ntravel.\n\n* * *"}, {"input": "7\n 3 3 4 5 4 5 3\n 5 3 4 4 2 3 2", "output": "29\n \n\n* * *"}, {"input": "1\n 2\n 3", "output": "5"}]
|
Print the maximum number of candies that can be collected.
* * *
|
s077424146
|
Accepted
|
p03449
|
Input is given from Standard Input in the following format:
N
A_{1, 1} A_{1, 2} ... A_{1, N}
A_{2, 1} A_{2, 2} ... A_{2, N}
|
n = int(input())
l = list(input().split())
r = list(input().split())
m = 0
for i in range(1, n + 1, 1):
a = 0
b = 0
for j in range(i):
A = int(l[j])
a += A
for j in range(i - 1, n, 1):
B = int(r[j])
b += B
if m < a + b:
m = a + b
print(m)
|
Statement
We have a 2 \times N grid. We will denote the square at the i-th row and j-th
column (1 \leq i \leq 2, 1 \leq j \leq N) as (i, j).
You are initially in the top-left square, (1, 1). You will travel to the
bottom-right square, (2, N), by repeatedly moving right or down.
The square (i, j) contains A_{i, j} candies. You will collect all the candies
you visit during the travel. The top-left and bottom-right squares also
contain candies, and you will also collect them.
At most how many candies can you collect when you choose the best way to
travel?
|
[{"input": "5\n 3 2 2 4 1\n 1 2 2 2 1", "output": "14\n \n\nThe number of collected candies will be maximized when you:\n\n * move right three times, then move down once, then move right once.\n\n* * *"}, {"input": "4\n 1 1 1 1\n 1 1 1 1", "output": "5\n \n\nYou will always collect the same number of candies, regardless of how you\ntravel.\n\n* * *"}, {"input": "7\n 3 3 4 5 4 5 3\n 5 3 4 4 2 3 2", "output": "29\n \n\n* * *"}, {"input": "1\n 2\n 3", "output": "5"}]
|
Print the maximum number of candies that can be collected.
* * *
|
s578057524
|
Accepted
|
p03449
|
Input is given from Standard Input in the following format:
N
A_{1, 1} A_{1, 2} ... A_{1, N}
A_{2, 1} A_{2, 2} ... A_{2, N}
|
# coding: utf-8
# hello worldと表示する
# coding: utf-8
# hello worldと表示する
retu = int(input())
gyo1 = list(map(int, input().split()))
gyo2 = list(map(int, input().split()))
num = 0
kai = 0
boss = []
for i in range(retu):
for ii in range(i + 1):
num += gyo1[ii]
for iii in range(retu - i):
num += gyo2[iii + i]
boss.append(num)
num = 0
# print(boss)
oss = sorted(boss)
print(oss[retu - 1])
|
Statement
We have a 2 \times N grid. We will denote the square at the i-th row and j-th
column (1 \leq i \leq 2, 1 \leq j \leq N) as (i, j).
You are initially in the top-left square, (1, 1). You will travel to the
bottom-right square, (2, N), by repeatedly moving right or down.
The square (i, j) contains A_{i, j} candies. You will collect all the candies
you visit during the travel. The top-left and bottom-right squares also
contain candies, and you will also collect them.
At most how many candies can you collect when you choose the best way to
travel?
|
[{"input": "5\n 3 2 2 4 1\n 1 2 2 2 1", "output": "14\n \n\nThe number of collected candies will be maximized when you:\n\n * move right three times, then move down once, then move right once.\n\n* * *"}, {"input": "4\n 1 1 1 1\n 1 1 1 1", "output": "5\n \n\nYou will always collect the same number of candies, regardless of how you\ntravel.\n\n* * *"}, {"input": "7\n 3 3 4 5 4 5 3\n 5 3 4 4 2 3 2", "output": "29\n \n\n* * *"}, {"input": "1\n 2\n 3", "output": "5"}]
|
Print the maximum number of candies that can be collected.
* * *
|
s788802809
|
Wrong Answer
|
p03449
|
Input is given from Standard Input in the following format:
N
A_{1, 1} A_{1, 2} ... A_{1, N}
A_{2, 1} A_{2, 2} ... A_{2, N}
|
N = int(input())
line_1 = list(map(int, input().split()))
line_2 = list(map(int, input().split()))
score_1 = sum(line_1[1:])
score_2 = sum(line_2[: N - 1])
total_score = line_1[0] + line_2[-1]
go_line_2 = False
for i in range(N - 1):
if not go_line_2 and score_1 >= score_2:
total_score += line_1[i + 1]
else:
total_score += line_2[i]
go_line_2 = True
score_1 -= line_1[i + 1]
score_2 -= line_2[i]
print(total_score)
"""
for i in range(N):
score_1 = sum(line_1[1 + i:])
score_2 = sum(line_2[i:N - 1])
if score_1 > score_2:
total_score += line_1[1 + i]
else:
total_score += line_2[i]
print(total_score)
"""
|
Statement
We have a 2 \times N grid. We will denote the square at the i-th row and j-th
column (1 \leq i \leq 2, 1 \leq j \leq N) as (i, j).
You are initially in the top-left square, (1, 1). You will travel to the
bottom-right square, (2, N), by repeatedly moving right or down.
The square (i, j) contains A_{i, j} candies. You will collect all the candies
you visit during the travel. The top-left and bottom-right squares also
contain candies, and you will also collect them.
At most how many candies can you collect when you choose the best way to
travel?
|
[{"input": "5\n 3 2 2 4 1\n 1 2 2 2 1", "output": "14\n \n\nThe number of collected candies will be maximized when you:\n\n * move right three times, then move down once, then move right once.\n\n* * *"}, {"input": "4\n 1 1 1 1\n 1 1 1 1", "output": "5\n \n\nYou will always collect the same number of candies, regardless of how you\ntravel.\n\n* * *"}, {"input": "7\n 3 3 4 5 4 5 3\n 5 3 4 4 2 3 2", "output": "29\n \n\n* * *"}, {"input": "1\n 2\n 3", "output": "5"}]
|
Print the maximum number of candies that can be collected.
* * *
|
s526771064
|
Runtime Error
|
p03449
|
Input is given from Standard Input in the following format:
N
A_{1, 1} A_{1, 2} ... A_{1, N}
A_{2, 1} A_{2, 2} ... A_{2, N}
|
N = int(input())
a = list(int(i) for i input().split())
b = list(int(i) for i input().split())
ans = 0
for n in range(N):
ap = a[:n]
bp = b[n-1:]
apsum = sum(ap)
bpsum = sum(bp)
s = apsum +bpsum
if s > ans:
ans = s
print(ans)
|
Statement
We have a 2 \times N grid. We will denote the square at the i-th row and j-th
column (1 \leq i \leq 2, 1 \leq j \leq N) as (i, j).
You are initially in the top-left square, (1, 1). You will travel to the
bottom-right square, (2, N), by repeatedly moving right or down.
The square (i, j) contains A_{i, j} candies. You will collect all the candies
you visit during the travel. The top-left and bottom-right squares also
contain candies, and you will also collect them.
At most how many candies can you collect when you choose the best way to
travel?
|
[{"input": "5\n 3 2 2 4 1\n 1 2 2 2 1", "output": "14\n \n\nThe number of collected candies will be maximized when you:\n\n * move right three times, then move down once, then move right once.\n\n* * *"}, {"input": "4\n 1 1 1 1\n 1 1 1 1", "output": "5\n \n\nYou will always collect the same number of candies, regardless of how you\ntravel.\n\n* * *"}, {"input": "7\n 3 3 4 5 4 5 3\n 5 3 4 4 2 3 2", "output": "29\n \n\n* * *"}, {"input": "1\n 2\n 3", "output": "5"}]
|
Print the maximum number of candies that can be collected.
* * *
|
s156030704
|
Runtime Error
|
p03449
|
Input is given from Standard Input in the following format:
N
A_{1, 1} A_{1, 2} ... A_{1, N}
A_{2, 1} A_{2, 2} ... A_{2, N}
|
n = int(input())
a = str(input()).split()
b = str(input()).split()
c = [a,b]
def max(x,y):
if x > y:
return x
else:
return y
def mp(v,w):
if v == 0 and w == 0:
return int(c[v][w])
elif v == 0:
return mp(v,(w - 1)) + int(c[v][w])
elif w == 0:
return mp((v - 1),w) + int(c[v][w])
else:
return max(mp(v,(w - 1)),mp((v - 1),w)) + int(c[v][w])
print(mp(1,(n-1)))
|
Statement
We have a 2 \times N grid. We will denote the square at the i-th row and j-th
column (1 \leq i \leq 2, 1 \leq j \leq N) as (i, j).
You are initially in the top-left square, (1, 1). You will travel to the
bottom-right square, (2, N), by repeatedly moving right or down.
The square (i, j) contains A_{i, j} candies. You will collect all the candies
you visit during the travel. The top-left and bottom-right squares also
contain candies, and you will also collect them.
At most how many candies can you collect when you choose the best way to
travel?
|
[{"input": "5\n 3 2 2 4 1\n 1 2 2 2 1", "output": "14\n \n\nThe number of collected candies will be maximized when you:\n\n * move right three times, then move down once, then move right once.\n\n* * *"}, {"input": "4\n 1 1 1 1\n 1 1 1 1", "output": "5\n \n\nYou will always collect the same number of candies, regardless of how you\ntravel.\n\n* * *"}, {"input": "7\n 3 3 4 5 4 5 3\n 5 3 4 4 2 3 2", "output": "29\n \n\n* * *"}, {"input": "1\n 2\n 3", "output": "5"}]
|
Print the maximum number of candies that can be collected.
* * *
|
s246498272
|
Runtime Error
|
p03449
|
Input is given from Standard Input in the following format:
N
A_{1, 1} A_{1, 2} ... A_{1, N}
A_{2, 1} A_{2, 2} ... A_{2, N}
|
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h>
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) REP(i,1,n+1)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> PII;
typedef vector<ll> Vl;
typedef vector<int> VI;
typedef tuple<int, int, int> TT;
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define dmt(x, y, z) make_tuple(x, y, z)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
const int MAX = 2000000;
const int inf = 1000000007;
const ll mod = 1000000007;
const ll longinf = 1LL << 60;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
int n, ans;
int a[2][100005];
int main() {
cin >> n;
rep(i, 2) {
rrep(j, n) {
int tmp;
cin >> tmp;
a[i][j] = a[i][j - 1] + tmp;
}
}
rrep(i, n) {
ans = max(ans, a[0][i] + (a[1][n] - a[1][i - 1]));
}
cout << ans << endl;
int heath=4;
return 0;
}
|
Statement
We have a 2 \times N grid. We will denote the square at the i-th row and j-th
column (1 \leq i \leq 2, 1 \leq j \leq N) as (i, j).
You are initially in the top-left square, (1, 1). You will travel to the
bottom-right square, (2, N), by repeatedly moving right or down.
The square (i, j) contains A_{i, j} candies. You will collect all the candies
you visit during the travel. The top-left and bottom-right squares also
contain candies, and you will also collect them.
At most how many candies can you collect when you choose the best way to
travel?
|
[{"input": "5\n 3 2 2 4 1\n 1 2 2 2 1", "output": "14\n \n\nThe number of collected candies will be maximized when you:\n\n * move right three times, then move down once, then move right once.\n\n* * *"}, {"input": "4\n 1 1 1 1\n 1 1 1 1", "output": "5\n \n\nYou will always collect the same number of candies, regardless of how you\ntravel.\n\n* * *"}, {"input": "7\n 3 3 4 5 4 5 3\n 5 3 4 4 2 3 2", "output": "29\n \n\n* * *"}, {"input": "1\n 2\n 3", "output": "5"}]
|
Print the maximum number of candies that can be collected.
* * *
|
s821234868
|
Runtime Error
|
p03449
|
Input is given from Standard Input in the following format:
N
A_{1, 1} A_{1, 2} ... A_{1, N}
A_{2, 1} A_{2, 2} ... A_{2, N}
|
N = int(input())
#maze = [[0] * (N + 10) for _ in range(2)]
maze = [list(map(int, input().split())) for _ in range(2)]
dp = [[0] * N for _ in range(2)]
dp[0][0] = maze[0][0]
for j in range(1, N):
dp[0][j] = dp[0][j - 1] + maze[0][j]]
dp[1][0] = dp[0][0] + maze[1][0]
for i in range(1, N):
dp[1][i] = max(dp[0][i] + maze[1][i], dp[1][i - 1] + maze[1][i])
print(dp[1][N - 1])
|
Statement
We have a 2 \times N grid. We will denote the square at the i-th row and j-th
column (1 \leq i \leq 2, 1 \leq j \leq N) as (i, j).
You are initially in the top-left square, (1, 1). You will travel to the
bottom-right square, (2, N), by repeatedly moving right or down.
The square (i, j) contains A_{i, j} candies. You will collect all the candies
you visit during the travel. The top-left and bottom-right squares also
contain candies, and you will also collect them.
At most how many candies can you collect when you choose the best way to
travel?
|
[{"input": "5\n 3 2 2 4 1\n 1 2 2 2 1", "output": "14\n \n\nThe number of collected candies will be maximized when you:\n\n * move right three times, then move down once, then move right once.\n\n* * *"}, {"input": "4\n 1 1 1 1\n 1 1 1 1", "output": "5\n \n\nYou will always collect the same number of candies, regardless of how you\ntravel.\n\n* * *"}, {"input": "7\n 3 3 4 5 4 5 3\n 5 3 4 4 2 3 2", "output": "29\n \n\n* * *"}, {"input": "1\n 2\n 3", "output": "5"}]
|
Print the maximum number of candies that can be collected.
* * *
|
s742629580
|
Runtime Error
|
p03449
|
Input is given from Standard Input in the following format:
N
A_{1, 1} A_{1, 2} ... A_{1, N}
A_{2, 1} A_{2, 2} ... A_{2, N}
|
N = int(input())
A = [[int(i) for i in input().split()] for j in range(2)]
count = 0
Max = 0
for i in range(N):
for j in range(i+1):
count += A[0][j]
for j in range(N-i):
count += A[1][i+j]
Max = max(Max, count
count = 0
print(Max)
|
Statement
We have a 2 \times N grid. We will denote the square at the i-th row and j-th
column (1 \leq i \leq 2, 1 \leq j \leq N) as (i, j).
You are initially in the top-left square, (1, 1). You will travel to the
bottom-right square, (2, N), by repeatedly moving right or down.
The square (i, j) contains A_{i, j} candies. You will collect all the candies
you visit during the travel. The top-left and bottom-right squares also
contain candies, and you will also collect them.
At most how many candies can you collect when you choose the best way to
travel?
|
[{"input": "5\n 3 2 2 4 1\n 1 2 2 2 1", "output": "14\n \n\nThe number of collected candies will be maximized when you:\n\n * move right three times, then move down once, then move right once.\n\n* * *"}, {"input": "4\n 1 1 1 1\n 1 1 1 1", "output": "5\n \n\nYou will always collect the same number of candies, regardless of how you\ntravel.\n\n* * *"}, {"input": "7\n 3 3 4 5 4 5 3\n 5 3 4 4 2 3 2", "output": "29\n \n\n* * *"}, {"input": "1\n 2\n 3", "output": "5"}]
|
Print the maximum number of candies that can be collected.
* * *
|
s972475593
|
Wrong Answer
|
p03449
|
Input is given from Standard Input in the following format:
N
A_{1, 1} A_{1, 2} ... A_{1, N}
A_{2, 1} A_{2, 2} ... A_{2, N}
|
import sys
line = sys.stdin.readlines()
print(line)
|
Statement
We have a 2 \times N grid. We will denote the square at the i-th row and j-th
column (1 \leq i \leq 2, 1 \leq j \leq N) as (i, j).
You are initially in the top-left square, (1, 1). You will travel to the
bottom-right square, (2, N), by repeatedly moving right or down.
The square (i, j) contains A_{i, j} candies. You will collect all the candies
you visit during the travel. The top-left and bottom-right squares also
contain candies, and you will also collect them.
At most how many candies can you collect when you choose the best way to
travel?
|
[{"input": "5\n 3 2 2 4 1\n 1 2 2 2 1", "output": "14\n \n\nThe number of collected candies will be maximized when you:\n\n * move right three times, then move down once, then move right once.\n\n* * *"}, {"input": "4\n 1 1 1 1\n 1 1 1 1", "output": "5\n \n\nYou will always collect the same number of candies, regardless of how you\ntravel.\n\n* * *"}, {"input": "7\n 3 3 4 5 4 5 3\n 5 3 4 4 2 3 2", "output": "29\n \n\n* * *"}, {"input": "1\n 2\n 3", "output": "5"}]
|
Print the maximum number of candies that can be collected.
* * *
|
s422314620
|
Runtime Error
|
p03449
|
Input is given from Standard Input in the following format:
N
A_{1, 1} A_{1, 2} ... A_{1, N}
A_{2, 1} A_{2, 2} ... A_{2, N}
|
N = int(input())
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
B1 = [0 * i for i in range(N)]
B2 = [0 * i for i in range(N)]
B1[0] = A1[0]
B2 = [0] = A2[0]
for i in range(0, N - 1):
B1[i + 1] = B1[i] + A1[i + 1]
B2[i + 1] = B2[i] + A2[i + 1]
maximum = B1[0] + B2[N - 1]
for i in range(1, N):
point = B1[i] + (B2[N - 1] - B2[i - 1])
maximum = max(maximum, point)
print(maximum)
|
Statement
We have a 2 \times N grid. We will denote the square at the i-th row and j-th
column (1 \leq i \leq 2, 1 \leq j \leq N) as (i, j).
You are initially in the top-left square, (1, 1). You will travel to the
bottom-right square, (2, N), by repeatedly moving right or down.
The square (i, j) contains A_{i, j} candies. You will collect all the candies
you visit during the travel. The top-left and bottom-right squares also
contain candies, and you will also collect them.
At most how many candies can you collect when you choose the best way to
travel?
|
[{"input": "5\n 3 2 2 4 1\n 1 2 2 2 1", "output": "14\n \n\nThe number of collected candies will be maximized when you:\n\n * move right three times, then move down once, then move right once.\n\n* * *"}, {"input": "4\n 1 1 1 1\n 1 1 1 1", "output": "5\n \n\nYou will always collect the same number of candies, regardless of how you\ntravel.\n\n* * *"}, {"input": "7\n 3 3 4 5 4 5 3\n 5 3 4 4 2 3 2", "output": "29\n \n\n* * *"}, {"input": "1\n 2\n 3", "output": "5"}]
|
Print the maximum number of candies that can be collected.
* * *
|
s851642387
|
Runtime Error
|
p03449
|
Input is given from Standard Input in the following format:
N
A_{1, 1} A_{1, 2} ... A_{1, N}
A_{2, 1} A_{2, 2} ... A_{2, N}
|
N = int(input())
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
B1 = [0 * i for i in range(N)]
B2 = [0 * i for i in range(N)]
B1[0] = A1[0]
B2 = [0] = A2[0]
for i in range(0, N - 1):
B1[i + 1] = B1[i] + A1[i + 1]
B2[i + 1] = B2[i] + A2[i + 1]
maximum = B1[0] + B2[N - 1]
for i in range(1, N):
point = B1[i] + (B2[N - 1] - B2[i - 1])
maximum = max(maximum, point)
print(maximum)
|
Statement
We have a 2 \times N grid. We will denote the square at the i-th row and j-th
column (1 \leq i \leq 2, 1 \leq j \leq N) as (i, j).
You are initially in the top-left square, (1, 1). You will travel to the
bottom-right square, (2, N), by repeatedly moving right or down.
The square (i, j) contains A_{i, j} candies. You will collect all the candies
you visit during the travel. The top-left and bottom-right squares also
contain candies, and you will also collect them.
At most how many candies can you collect when you choose the best way to
travel?
|
[{"input": "5\n 3 2 2 4 1\n 1 2 2 2 1", "output": "14\n \n\nThe number of collected candies will be maximized when you:\n\n * move right three times, then move down once, then move right once.\n\n* * *"}, {"input": "4\n 1 1 1 1\n 1 1 1 1", "output": "5\n \n\nYou will always collect the same number of candies, regardless of how you\ntravel.\n\n* * *"}, {"input": "7\n 3 3 4 5 4 5 3\n 5 3 4 4 2 3 2", "output": "29\n \n\n* * *"}, {"input": "1\n 2\n 3", "output": "5"}]
|
Print N lines. The i-th line should contain the value f(i).
* * *
|
s635473310
|
Wrong Answer
|
p02608
|
Input is given from Standard Input in the following format:
N
|
def sum_(x, y, z):
return (((x + y) ** 2) + ((y + z) ** 2) + ((x + z) ** 2)) // 2
n = int(input())
l = [0] * (n + 1)
i = 1
while i < n and sum_(i, i, i) <= n:
z = 1
while z < n and sum_(i, i, z) <= n:
if i == z:
l[sum_(i, i, z)] += 1
else:
l[sum_(i, i, z)] += 3
z += 1
i += 1
i = 1
while i < n and sum_(i, i + 1, i + 2) <= n:
y = i + 1
while sum_(i, y, y + 1) <= n:
z = y + 1
while sum_(i, y, z) <= n:
l[sum_(i, y, z)] += 6
z += 1
y += 1
i += 1
for i in l[1:]:
print(i)
|
Statement
Let f(n) be the number of triples of integers (x,y,z) that satisfy both of the
following conditions:
* 1 \leq x,y,z
* x^2 + y^2 + z^2 + xy + yz + zx = n
Given an integer N, find each of f(1),f(2),f(3),\ldots,f(N).
|
[{"input": "20", "output": "0\n 0\n 0\n 0\n 0\n 1\n 0\n 0\n 0\n 0\n 3\n 0\n 0\n 0\n 0\n 0\n 3\n 3\n 0\n 0\n \n\n * For n=6, only (1,1,1) satisfies both of the conditions. Thus, f(6) = 1.\n * For n=11, three triples, (1,1,2), (1,2,1), and (2,1,1), satisfy both of the conditions. Thus, f(6) = 3.\n * For n=17, three triples, (1,2,2), (2,1,2), and (2,2,1), satisfy both of the conditions. Thus, f(17) = 3.\n * For n=18, three triples, (1,1,3), (1,3,1), and (3,1,1), satisfy both of the conditions. Thus, f(18) = 3."}]
|
Print N lines. The i-th line should contain the value f(i).
* * *
|
s304580182
|
Wrong Answer
|
p02608
|
Input is given from Standard Input in the following format:
N
|
n = int(input())
for i in range(1, n + 1):
a = 0
ii = int((i**0.5) + 1)
x = 1
for x in range(1, (ii // 3) + 1):
y = x
while x + (2 * y) <= ii:
z = ii - x - y
if (x**2) + (y**2) + (z**2) + (x * y) + (y * z) + (z * x) == i:
if x == y == z:
a += 1
elif x < y <= z or x <= y < z:
a += 3
elif x < y < z:
a += 6
y += 1
x += 1
print(a)
|
Statement
Let f(n) be the number of triples of integers (x,y,z) that satisfy both of the
following conditions:
* 1 \leq x,y,z
* x^2 + y^2 + z^2 + xy + yz + zx = n
Given an integer N, find each of f(1),f(2),f(3),\ldots,f(N).
|
[{"input": "20", "output": "0\n 0\n 0\n 0\n 0\n 1\n 0\n 0\n 0\n 0\n 3\n 0\n 0\n 0\n 0\n 0\n 3\n 3\n 0\n 0\n \n\n * For n=6, only (1,1,1) satisfies both of the conditions. Thus, f(6) = 1.\n * For n=11, three triples, (1,1,2), (1,2,1), and (2,1,1), satisfy both of the conditions. Thus, f(6) = 3.\n * For n=17, three triples, (1,2,2), (2,1,2), and (2,2,1), satisfy both of the conditions. Thus, f(17) = 3.\n * For n=18, three triples, (1,1,3), (1,3,1), and (3,1,1), satisfy both of the conditions. Thus, f(18) = 3."}]
|
Print N lines. The i-th line should contain the value f(i).
* * *
|
s698902723
|
Accepted
|
p02608
|
Input is given from Standard Input in the following format:
N
|
L = 10**2 + 10
n = int(input())
ans = [0] * n
for i in range(1, L):
for j in range(1, L):
for k in range(1, L):
x = i**2 + j**2 + k**2 + i * j + j * k + i * k
if x <= n:
ans[x - 1] += 1
print(*ans, sep="\n")
|
Statement
Let f(n) be the number of triples of integers (x,y,z) that satisfy both of the
following conditions:
* 1 \leq x,y,z
* x^2 + y^2 + z^2 + xy + yz + zx = n
Given an integer N, find each of f(1),f(2),f(3),\ldots,f(N).
|
[{"input": "20", "output": "0\n 0\n 0\n 0\n 0\n 1\n 0\n 0\n 0\n 0\n 3\n 0\n 0\n 0\n 0\n 0\n 3\n 3\n 0\n 0\n \n\n * For n=6, only (1,1,1) satisfies both of the conditions. Thus, f(6) = 1.\n * For n=11, three triples, (1,1,2), (1,2,1), and (2,1,1), satisfy both of the conditions. Thus, f(6) = 3.\n * For n=17, three triples, (1,2,2), (2,1,2), and (2,2,1), satisfy both of the conditions. Thus, f(17) = 3.\n * For n=18, three triples, (1,1,3), (1,3,1), and (3,1,1), satisfy both of the conditions. Thus, f(18) = 3."}]
|
Print N lines. The i-th line should contain the value f(i).
* * *
|
s452887300
|
Wrong Answer
|
p02608
|
Input is given from Standard Input in the following format:
N
|
print
|
Statement
Let f(n) be the number of triples of integers (x,y,z) that satisfy both of the
following conditions:
* 1 \leq x,y,z
* x^2 + y^2 + z^2 + xy + yz + zx = n
Given an integer N, find each of f(1),f(2),f(3),\ldots,f(N).
|
[{"input": "20", "output": "0\n 0\n 0\n 0\n 0\n 1\n 0\n 0\n 0\n 0\n 3\n 0\n 0\n 0\n 0\n 0\n 3\n 3\n 0\n 0\n \n\n * For n=6, only (1,1,1) satisfies both of the conditions. Thus, f(6) = 1.\n * For n=11, three triples, (1,1,2), (1,2,1), and (2,1,1), satisfy both of the conditions. Thus, f(6) = 3.\n * For n=17, three triples, (1,2,2), (2,1,2), and (2,2,1), satisfy both of the conditions. Thus, f(17) = 3.\n * For n=18, three triples, (1,1,3), (1,3,1), and (3,1,1), satisfy both of the conditions. Thus, f(18) = 3."}]
|
Print N lines. The i-th line should contain the value f(i).
* * *
|
s861570539
|
Wrong Answer
|
p02608
|
Input is given from Standard Input in the following format:
N
|
import itertools
def calculateFunction(x, y, z):
triplePattern = 1
doublePattern = 3
notEqualPattern = 6
tmp = x + y + z
returnValue = tmp * tmp - (x * y + y * z + z * x)
if x == y:
if y == z:
return triplePattern, returnValue
else:
return doublePattern, returnValue
elif y == z:
return doublePattern, returnValue
else:
return notEqualPattern, returnValue
lis = []
for i in range(42):
lis.append(i + 1)
fullset = [0] * 10000
for team in itertools.product(lis, repeat=3):
targetValue, ans = calculateFunction(team[0], team[1], team[2])
if ans <= 10000:
fullset[ans - 1] += 1
X = int(input())
for i in range(X):
print(fullset[i])
|
Statement
Let f(n) be the number of triples of integers (x,y,z) that satisfy both of the
following conditions:
* 1 \leq x,y,z
* x^2 + y^2 + z^2 + xy + yz + zx = n
Given an integer N, find each of f(1),f(2),f(3),\ldots,f(N).
|
[{"input": "20", "output": "0\n 0\n 0\n 0\n 0\n 1\n 0\n 0\n 0\n 0\n 3\n 0\n 0\n 0\n 0\n 0\n 3\n 3\n 0\n 0\n \n\n * For n=6, only (1,1,1) satisfies both of the conditions. Thus, f(6) = 1.\n * For n=11, three triples, (1,1,2), (1,2,1), and (2,1,1), satisfy both of the conditions. Thus, f(6) = 3.\n * For n=17, three triples, (1,2,2), (2,1,2), and (2,2,1), satisfy both of the conditions. Thus, f(17) = 3.\n * For n=18, three triples, (1,1,3), (1,3,1), and (3,1,1), satisfy both of the conditions. Thus, f(18) = 3."}]
|
Print N lines. The i-th line should contain the value f(i).
* * *
|
s090812274
|
Accepted
|
p02608
|
Input is given from Standard Input in the following format:
N
|
import math
N = int(input())
# f(n) を以下の 2 つの条件の両方を満たすような 3 つの整数の組 (x,y,z)の個数とします。
# 1≤x,y,z
# x**2 + y**2 + z**2 + xy + yz + zx = n
# x,y,zの最大値を考える。
# x**2 + 1**2 + 1**2 + x + 1 + x = n
# x**2 + 2x = n - 3
# x**2 + 2x -n + 3 = 0
# x = {-2 ± sqrt(2**2 - 4*1*(-n+3))}/2*1
# x = {-2 ± sqrt(4 + 4n -12)}/2
# 1 ≤ xより
# x = {-2 + sqrt(4n - 8)}/2 = {-2 + 2 * sqrt(n - 2)}/2 = -1 + sqrt(n - 2)
# ∴ 1 ≤ x ≤ math.floor(-1 + sqrt(n - 2))
# y,zも同様。
# N <= 10**4 より、x,y,xで全探索しても(10**2)**3 = 10**6 で間に合う
ans_dict = {i: set() for i in range(1, N + 1)}
if N != 1:
for i in range(1, 1 + math.floor(-1 + math.sqrt(N - 2))):
for j in range(1, 1 + math.floor(-1 + math.sqrt(N - 2))):
for k in range(1, 1 + math.floor(-1 + math.sqrt(N - 2))):
n = i**2 + j**2 + k**2 + i * j + j * k + k * i
if 1 <= n <= N:
ans_dict[n].add((i, j, k))
for i in range(1, N + 1):
print(len(ans_dict[i]))
else:
print(0)
|
Statement
Let f(n) be the number of triples of integers (x,y,z) that satisfy both of the
following conditions:
* 1 \leq x,y,z
* x^2 + y^2 + z^2 + xy + yz + zx = n
Given an integer N, find each of f(1),f(2),f(3),\ldots,f(N).
|
[{"input": "20", "output": "0\n 0\n 0\n 0\n 0\n 1\n 0\n 0\n 0\n 0\n 3\n 0\n 0\n 0\n 0\n 0\n 3\n 3\n 0\n 0\n \n\n * For n=6, only (1,1,1) satisfies both of the conditions. Thus, f(6) = 1.\n * For n=11, three triples, (1,1,2), (1,2,1), and (2,1,1), satisfy both of the conditions. Thus, f(6) = 3.\n * For n=17, three triples, (1,2,2), (2,1,2), and (2,2,1), satisfy both of the conditions. Thus, f(17) = 3.\n * For n=18, three triples, (1,1,3), (1,3,1), and (3,1,1), satisfy both of the conditions. Thus, f(18) = 3."}]
|
Print N lines. The i-th line should contain the value f(i).
* * *
|
s029194043
|
Wrong Answer
|
p02608
|
Input is given from Standard Input in the following format:
N
|
input_number = input()
for n in range(int(input_number)):
n += 1
count = 0
for x in range(100):
for y in range(100):
for z in range(100):
function = x*x+y*y+z*z+x*y+y*z+x*z
if n == function:
count += 1
print(count)
|
Statement
Let f(n) be the number of triples of integers (x,y,z) that satisfy both of the
following conditions:
* 1 \leq x,y,z
* x^2 + y^2 + z^2 + xy + yz + zx = n
Given an integer N, find each of f(1),f(2),f(3),\ldots,f(N).
|
[{"input": "20", "output": "0\n 0\n 0\n 0\n 0\n 1\n 0\n 0\n 0\n 0\n 3\n 0\n 0\n 0\n 0\n 0\n 3\n 3\n 0\n 0\n \n\n * For n=6, only (1,1,1) satisfies both of the conditions. Thus, f(6) = 1.\n * For n=11, three triples, (1,1,2), (1,2,1), and (2,1,1), satisfy both of the conditions. Thus, f(6) = 3.\n * For n=17, three triples, (1,2,2), (2,1,2), and (2,2,1), satisfy both of the conditions. Thus, f(17) = 3.\n * For n=18, three triples, (1,1,3), (1,3,1), and (3,1,1), satisfy both of the conditions. Thus, f(18) = 3."}]
|
Print N lines. The i-th line should contain the value f(i).
* * *
|
s587785349
|
Wrong Answer
|
p02608
|
Input is given from Standard Input in the following format:
N
|
num_limit = int(input())
s_limit = int(num_limit**0.5)
for i in range(1, num_limit + 1):
xyz_list = []
if i >= 1 and i <= 5:
print(0)
else:
s_limit = int(i**0.5)
for j in range(1, s_limit + 1):
for k in range(1, s_limit + 1):
for l in range(1, s_limit + 1):
if i == j**2 + k**2 + l**2 + j * k + k * l + l * j:
xyz_list.append([i, j, k])
print(len(xyz_list))
|
Statement
Let f(n) be the number of triples of integers (x,y,z) that satisfy both of the
following conditions:
* 1 \leq x,y,z
* x^2 + y^2 + z^2 + xy + yz + zx = n
Given an integer N, find each of f(1),f(2),f(3),\ldots,f(N).
|
[{"input": "20", "output": "0\n 0\n 0\n 0\n 0\n 1\n 0\n 0\n 0\n 0\n 3\n 0\n 0\n 0\n 0\n 0\n 3\n 3\n 0\n 0\n \n\n * For n=6, only (1,1,1) satisfies both of the conditions. Thus, f(6) = 1.\n * For n=11, three triples, (1,1,2), (1,2,1), and (2,1,1), satisfy both of the conditions. Thus, f(6) = 3.\n * For n=17, three triples, (1,2,2), (2,1,2), and (2,2,1), satisfy both of the conditions. Thus, f(17) = 3.\n * For n=18, three triples, (1,1,3), (1,3,1), and (3,1,1), satisfy both of the conditions. Thus, f(18) = 3."}]
|
Print N lines. The i-th line should contain the value f(i).
* * *
|
s172783434
|
Accepted
|
p02608
|
Input is given from Standard Input in the following format:
N
|
n = int(input())
ans = [0]*n
#print(ans)
for x in range(1,101):
for y in range(1,101):
for z in range(1,101):
temp = x**2+y**2+z**2+x*y+y*z+z*x
if temp <= n:
#print(temp)
ans[temp-1] += 1
[print(ans[i]) for i in range(n)]
|
Statement
Let f(n) be the number of triples of integers (x,y,z) that satisfy both of the
following conditions:
* 1 \leq x,y,z
* x^2 + y^2 + z^2 + xy + yz + zx = n
Given an integer N, find each of f(1),f(2),f(3),\ldots,f(N).
|
[{"input": "20", "output": "0\n 0\n 0\n 0\n 0\n 1\n 0\n 0\n 0\n 0\n 3\n 0\n 0\n 0\n 0\n 0\n 3\n 3\n 0\n 0\n \n\n * For n=6, only (1,1,1) satisfies both of the conditions. Thus, f(6) = 1.\n * For n=11, three triples, (1,1,2), (1,2,1), and (2,1,1), satisfy both of the conditions. Thus, f(6) = 3.\n * For n=17, three triples, (1,2,2), (2,1,2), and (2,2,1), satisfy both of the conditions. Thus, f(17) = 3.\n * For n=18, three triples, (1,1,3), (1,3,1), and (3,1,1), satisfy both of the conditions. Thus, f(18) = 3."}]
|
Print N lines. The i-th line should contain the value f(i).
* * *
|
s780344149
|
Wrong Answer
|
p02608
|
Input is given from Standard Input in the following format:
N
|
n = int(input())
A = [0] * n
for i in range(3, int(n**0.5 + 150)):
for j in range(1, i - 1):
for k in range(1, i - j):
if (x := i * i - j * k - k * (l := i - j - k) - l * j) <= n:
A[x - 1] += 1
print(A[-30:-1])
|
Statement
Let f(n) be the number of triples of integers (x,y,z) that satisfy both of the
following conditions:
* 1 \leq x,y,z
* x^2 + y^2 + z^2 + xy + yz + zx = n
Given an integer N, find each of f(1),f(2),f(3),\ldots,f(N).
|
[{"input": "20", "output": "0\n 0\n 0\n 0\n 0\n 1\n 0\n 0\n 0\n 0\n 3\n 0\n 0\n 0\n 0\n 0\n 3\n 3\n 0\n 0\n \n\n * For n=6, only (1,1,1) satisfies both of the conditions. Thus, f(6) = 1.\n * For n=11, three triples, (1,1,2), (1,2,1), and (2,1,1), satisfy both of the conditions. Thus, f(6) = 3.\n * For n=17, three triples, (1,2,2), (2,1,2), and (2,2,1), satisfy both of the conditions. Thus, f(17) = 3.\n * For n=18, three triples, (1,1,3), (1,3,1), and (3,1,1), satisfy both of the conditions. Thus, f(18) = 3."}]
|
Print the maximum value in a line.
|
s724980421
|
Wrong Answer
|
p02258
|
The first line contains an integer $n$. In the following $n$ lines, $R_t$ ($t
= 0, 1, 2, ... n-1$) are given in order.
|
# f(j)-f(i)最大値を求める
input1 = [6, 5, 4, 1, 3, 4, 3]
max1 = input1[0]
min1 = input1[0]
for i in input1:
if max1 < i:
max1 = i
if min1 > i:
min1 = i
print("MAX:{} MIN:{}".format(max1, min1))
|
Maximum Profit
You can obtain profits from foreign exchange margin transactions. For example,
if you buy 1000 dollar at a rate of 100 yen per dollar, and sell them at a
rate of 108 yen per dollar, you can obtain (108 - 100) × 1000 = 8000 yen.
Write a program which reads values of a currency $R_t$ at a certain time $t$
($t = 0, 1, 2, ... n-1$), and reports the maximum value of $R_j - R_i$ where
$j > i$ .
|
[{"input": "6\n 5\n 3\n 1\n 3\n 4\n 3", "output": "3"}, {"input": "3\n 4\n 3\n 2", "output": "-1"}]
|
Print the maximum value in a line.
|
s624106782
|
Wrong Answer
|
p02258
|
The first line contains an integer $n$. In the following $n$ lines, $R_t$ ($t
= 0, 1, 2, ... n-1$) are given in order.
|
n = int(input())
L = [int(input()) for i in range(n)]
minv = L[0]
maxv = 0
for i in range(n):
maxv = max(maxv, L[i] - minv)
minv = min(minv, L[i])
if maxv >= 0:
print(maxv)
else:
print(-minv)
|
Maximum Profit
You can obtain profits from foreign exchange margin transactions. For example,
if you buy 1000 dollar at a rate of 100 yen per dollar, and sell them at a
rate of 108 yen per dollar, you can obtain (108 - 100) × 1000 = 8000 yen.
Write a program which reads values of a currency $R_t$ at a certain time $t$
($t = 0, 1, 2, ... n-1$), and reports the maximum value of $R_j - R_i$ where
$j > i$ .
|
[{"input": "6\n 5\n 3\n 1\n 3\n 4\n 3", "output": "3"}, {"input": "3\n 4\n 3\n 2", "output": "-1"}]
|
Print the maximum value in a line.
|
s544503801
|
Wrong Answer
|
p02258
|
The first line contains an integer $n$. In the following $n$ lines, $R_t$ ($t
= 0, 1, 2, ... n-1$) are given in order.
|
N = int(input())
M = -1000000000
L = int(input())
for i in range(2, N):
C = int(input())
M = max(C - L, M)
L = min(C, L)
print(M)
|
Maximum Profit
You can obtain profits from foreign exchange margin transactions. For example,
if you buy 1000 dollar at a rate of 100 yen per dollar, and sell them at a
rate of 108 yen per dollar, you can obtain (108 - 100) × 1000 = 8000 yen.
Write a program which reads values of a currency $R_t$ at a certain time $t$
($t = 0, 1, 2, ... n-1$), and reports the maximum value of $R_j - R_i$ where
$j > i$ .
|
[{"input": "6\n 5\n 3\n 1\n 3\n 4\n 3", "output": "3"}, {"input": "3\n 4\n 3\n 2", "output": "-1"}]
|
Print the maximum value in a line.
|
s925744698
|
Wrong Answer
|
p02258
|
The first line contains an integer $n$. In the following $n$ lines, $R_t$ ($t
= 0, 1, 2, ... n-1$) are given in order.
|
n = int(input().strip())
elem = 0
a = []
sub = []
for i in range(n):
elem = int(input().strip())
a.append(elem)
for i in range(1, len(a)):
elem = a[i] - a[i - 1]
if elem not in sub:
sub.append(elem)
print(max(sub))
|
Maximum Profit
You can obtain profits from foreign exchange margin transactions. For example,
if you buy 1000 dollar at a rate of 100 yen per dollar, and sell them at a
rate of 108 yen per dollar, you can obtain (108 - 100) × 1000 = 8000 yen.
Write a program which reads values of a currency $R_t$ at a certain time $t$
($t = 0, 1, 2, ... n-1$), and reports the maximum value of $R_j - R_i$ where
$j > i$ .
|
[{"input": "6\n 5\n 3\n 1\n 3\n 4\n 3", "output": "3"}, {"input": "3\n 4\n 3\n 2", "output": "-1"}]
|
Print the maximum value in a line.
|
s170096196
|
Wrong Answer
|
p02258
|
The first line contains an integer $n$. In the following $n$ lines, $R_t$ ($t
= 0, 1, 2, ... n-1$) are given in order.
|
n = int(input())
r = []
for i in range(n):
r.append(int(input()))
# m=sorted(r, reverse=True)
p = max(r[1:])
s = sorted(r, reverse=True)
q = min(s[s.index(p) + 1 :])
a = p - q
q = min(r[: len(r) - 1])
# print(q)
p = max(r[r.index(q) + 1 :])
# print(p)
b = p - q
# print(b)
print(max(a, b))
|
Maximum Profit
You can obtain profits from foreign exchange margin transactions. For example,
if you buy 1000 dollar at a rate of 100 yen per dollar, and sell them at a
rate of 108 yen per dollar, you can obtain (108 - 100) × 1000 = 8000 yen.
Write a program which reads values of a currency $R_t$ at a certain time $t$
($t = 0, 1, 2, ... n-1$), and reports the maximum value of $R_j - R_i$ where
$j > i$ .
|
[{"input": "6\n 5\n 3\n 1\n 3\n 4\n 3", "output": "3"}, {"input": "3\n 4\n 3\n 2", "output": "-1"}]
|
Print the maximum value in a line.
|
s043291755
|
Accepted
|
p02258
|
The first line contains an integer $n$. In the following $n$ lines, $R_t$ ($t
= 0, 1, 2, ... n-1$) are given in order.
|
lines = int(input())
mini = int(input())
maxi = -1000000000
for i in range(1, lines):
s = int(input())
maxi = max(maxi, s - mini)
mini = min(s, mini)
print(maxi)
|
Maximum Profit
You can obtain profits from foreign exchange margin transactions. For example,
if you buy 1000 dollar at a rate of 100 yen per dollar, and sell them at a
rate of 108 yen per dollar, you can obtain (108 - 100) × 1000 = 8000 yen.
Write a program which reads values of a currency $R_t$ at a certain time $t$
($t = 0, 1, 2, ... n-1$), and reports the maximum value of $R_j - R_i$ where
$j > i$ .
|
[{"input": "6\n 5\n 3\n 1\n 3\n 4\n 3", "output": "3"}, {"input": "3\n 4\n 3\n 2", "output": "-1"}]
|
Print the maximum value in a line.
|
s895255113
|
Accepted
|
p02258
|
The first line contains an integer $n$. In the following $n$ lines, $R_t$ ($t
= 0, 1, 2, ... n-1$) are given in order.
|
n = int(input())
lst = [int(input()) for i in range(n)]
vmin, vmax = lst.pop(0), -1000000000000
for i in lst:
vmax = max(vmax, i - vmin)
vmin = min(vmin, i)
print(vmax)
|
Maximum Profit
You can obtain profits from foreign exchange margin transactions. For example,
if you buy 1000 dollar at a rate of 100 yen per dollar, and sell them at a
rate of 108 yen per dollar, you can obtain (108 - 100) × 1000 = 8000 yen.
Write a program which reads values of a currency $R_t$ at a certain time $t$
($t = 0, 1, 2, ... n-1$), and reports the maximum value of $R_j - R_i$ where
$j > i$ .
|
[{"input": "6\n 5\n 3\n 1\n 3\n 4\n 3", "output": "3"}, {"input": "3\n 4\n 3\n 2", "output": "-1"}]
|
Print the maximum value in a line.
|
s315685823
|
Accepted
|
p02258
|
The first line contains an integer $n$. In the following $n$ lines, $R_t$ ($t
= 0, 1, 2, ... n-1$) are given in order.
|
min_r = 10**9
max_raise = (10**9 * -1) + 1
n = int(input())
r = int(input())
min_r = min(min_r, r)
for n in range(n - 1):
r = int(input())
max_raise = max(max_raise, (r - min_r))
min_r = min(min_r, r)
print(max_raise)
|
Maximum Profit
You can obtain profits from foreign exchange margin transactions. For example,
if you buy 1000 dollar at a rate of 100 yen per dollar, and sell them at a
rate of 108 yen per dollar, you can obtain (108 - 100) × 1000 = 8000 yen.
Write a program which reads values of a currency $R_t$ at a certain time $t$
($t = 0, 1, 2, ... n-1$), and reports the maximum value of $R_j - R_i$ where
$j > i$ .
|
[{"input": "6\n 5\n 3\n 1\n 3\n 4\n 3", "output": "3"}, {"input": "3\n 4\n 3\n 2", "output": "-1"}]
|
Print the maximum value in a line.
|
s227567418
|
Accepted
|
p02258
|
The first line contains an integer $n$. In the following $n$ lines, $R_t$ ($t
= 0, 1, 2, ... n-1$) are given in order.
|
n = int(input())
if n > 1:
p1 = int(input())
p2 = int(input())
maxi = p2 - p1
mini = min(p1, p2)
for i in range(n - 2):
current = int(input())
maxi = max(maxi, current - mini)
mini = min(mini, current)
print(maxi)
|
Maximum Profit
You can obtain profits from foreign exchange margin transactions. For example,
if you buy 1000 dollar at a rate of 100 yen per dollar, and sell them at a
rate of 108 yen per dollar, you can obtain (108 - 100) × 1000 = 8000 yen.
Write a program which reads values of a currency $R_t$ at a certain time $t$
($t = 0, 1, 2, ... n-1$), and reports the maximum value of $R_j - R_i$ where
$j > i$ .
|
[{"input": "6\n 5\n 3\n 1\n 3\n 4\n 3", "output": "3"}, {"input": "3\n 4\n 3\n 2", "output": "-1"}]
|
Print the maximum value in a line.
|
s154543371
|
Accepted
|
p02258
|
The first line contains an integer $n$. In the following $n$ lines, $R_t$ ($t
= 0, 1, 2, ... n-1$) are given in order.
|
n = int(input())
a = int(input())
b = int(input())
max_value = b - a
min_number = min(a, b)
for j in range(n - 2):
r = int(input())
max_value = max(max_value, r - min_number)
min_number = min(min_number, r)
print(max_value)
|
Maximum Profit
You can obtain profits from foreign exchange margin transactions. For example,
if you buy 1000 dollar at a rate of 100 yen per dollar, and sell them at a
rate of 108 yen per dollar, you can obtain (108 - 100) × 1000 = 8000 yen.
Write a program which reads values of a currency $R_t$ at a certain time $t$
($t = 0, 1, 2, ... n-1$), and reports the maximum value of $R_j - R_i$ where
$j > i$ .
|
[{"input": "6\n 5\n 3\n 1\n 3\n 4\n 3", "output": "3"}, {"input": "3\n 4\n 3\n 2", "output": "-1"}]
|
Print the maximum value in a line.
|
s824620616
|
Accepted
|
p02258
|
The first line contains an integer $n$. In the following $n$ lines, $R_t$ ($t
= 0, 1, 2, ... n-1$) are given in order.
|
# region
import sys
import itertools
DEBUG = True if (len(sys.argv) > 1 and sys.argv[1] == "DEBUG") else False
def dp(value):
if DEBUG:
print(value)
return
def input_text(split=" "):
# 入力
result = []
while True:
try:
row = list(
map(lambda x: int(x) if x.isdecimal() else x, input().split(split))
)
result.append(row)
except EOFError:
break
return result
# endregion
it = input_text()
r = list(itertools.chain.from_iterable(it[1:]))
r_min = sys.maxsize
diff_max = -sys.maxsize
if len(r) == 0:
print(0)
sys.exit()
for rj in r:
dif = rj - r_min
if diff_max < dif:
diff_max = dif
if rj < r_min:
r_min = rj
print(diff_max)
|
Maximum Profit
You can obtain profits from foreign exchange margin transactions. For example,
if you buy 1000 dollar at a rate of 100 yen per dollar, and sell them at a
rate of 108 yen per dollar, you can obtain (108 - 100) × 1000 = 8000 yen.
Write a program which reads values of a currency $R_t$ at a certain time $t$
($t = 0, 1, 2, ... n-1$), and reports the maximum value of $R_j - R_i$ where
$j > i$ .
|
[{"input": "6\n 5\n 3\n 1\n 3\n 4\n 3", "output": "3"}, {"input": "3\n 4\n 3\n 2", "output": "-1"}]
|
Print the maximum value in a line.
|
s736622356
|
Accepted
|
p02258
|
The first line contains an integer $n$. In the following $n$ lines, $R_t$ ($t
= 0, 1, 2, ... n-1$) are given in order.
|
R = [int(input()) for i in range(int(input()))]
dfmx = -(10**10)
mn = 10**10
for i in range(len(R)):
dfmx = max(R[i] - mn, dfmx)
mn = min(R[i], mn)
print(dfmx)
|
Maximum Profit
You can obtain profits from foreign exchange margin transactions. For example,
if you buy 1000 dollar at a rate of 100 yen per dollar, and sell them at a
rate of 108 yen per dollar, you can obtain (108 - 100) × 1000 = 8000 yen.
Write a program which reads values of a currency $R_t$ at a certain time $t$
($t = 0, 1, 2, ... n-1$), and reports the maximum value of $R_j - R_i$ where
$j > i$ .
|
[{"input": "6\n 5\n 3\n 1\n 3\n 4\n 3", "output": "3"}, {"input": "3\n 4\n 3\n 2", "output": "-1"}]
|
Print the maximum value in a line.
|
s696931738
|
Wrong Answer
|
p02258
|
The first line contains an integer $n$. In the following $n$ lines, $R_t$ ($t
= 0, 1, 2, ... n-1$) are given in order.
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
input:
6
5
3
1
3
4
3
output:
3
"""
import sys
def solve():
# write your code here
max_profit = 0
min_stock = prices[0]
for price in prices[1:]:
max_profit = max(max_profit, price - min_stock)
min_stock = min(min_stock, price)
return max_profit if max_profit else -1
if __name__ == "__main__":
_input = sys.stdin.readlines()
p_num = int(_input[0])
prices = list(map(int, _input[1:]))
print(solve())
|
Maximum Profit
You can obtain profits from foreign exchange margin transactions. For example,
if you buy 1000 dollar at a rate of 100 yen per dollar, and sell them at a
rate of 108 yen per dollar, you can obtain (108 - 100) × 1000 = 8000 yen.
Write a program which reads values of a currency $R_t$ at a certain time $t$
($t = 0, 1, 2, ... n-1$), and reports the maximum value of $R_j - R_i$ where
$j > i$ .
|
[{"input": "6\n 5\n 3\n 1\n 3\n 4\n 3", "output": "3"}, {"input": "3\n 4\n 3\n 2", "output": "-1"}]
|
Print the maximum value in a line.
|
s860206214
|
Accepted
|
p02258
|
The first line contains an integer $n$. In the following $n$ lines, $R_t$ ($t
= 0, 1, 2, ... n-1$) are given in order.
|
n, *A = map(int, open(0).read().split())
m = A[0]
M = -float("inf")
for a in A[1:]:
M = max(M, a - m)
m = min(m, a)
print(M)
|
Maximum Profit
You can obtain profits from foreign exchange margin transactions. For example,
if you buy 1000 dollar at a rate of 100 yen per dollar, and sell them at a
rate of 108 yen per dollar, you can obtain (108 - 100) × 1000 = 8000 yen.
Write a program which reads values of a currency $R_t$ at a certain time $t$
($t = 0, 1, 2, ... n-1$), and reports the maximum value of $R_j - R_i$ where
$j > i$ .
|
[{"input": "6\n 5\n 3\n 1\n 3\n 4\n 3", "output": "3"}, {"input": "3\n 4\n 3\n 2", "output": "-1"}]
|
For each dataset, prints the number of prime numbers.
|
s057805712
|
Wrong Answer
|
p00009
|
Input consists of several datasets. Each dataset has an integer n (1 ≤ n ≤
999,999) in a line.
The number of datasets is less than or equal to 30.
|
t = 0
while t == 0:
prime = [2, 3]
try:
n = int(input())
except:
break
# ?¨??????\???????????????????¨????
else:
if n == 1:
# 1?????????
print(0)
elif n == 2:
print(1)
elif n <= 4:
print(2)
else:
a = 5
while a > n:
# 5??\????????????
total = len(prime)
# ?´???°?????°?????????
for b in prime:
if a % b == 0:
break
# ?´???°??????????????´????????????
else:
if total == 0:
# ?´???°?¢?????????????
prime.append(a)
else:
# ?´???°??¢?´¢??°??????
total -= 1
if (a + 1) % 6 == 0:
a += 2
else:
a += 5
print(len(prime))
|
Prime Number
Write a program which reads an integer n and prints the number of prime
numbers which are less than or equal to n. A prime number is a natural number
which has exactly two distinct natural number divisors: 1 and itself. For
example, the first four prime numbers are: 2, 3, 5 and 7.
|
[{"input": "3\n 11", "output": "2\n 5"}]
|
For each dataset, prints the number of prime numbers.
|
s711965774
|
Wrong Answer
|
p00009
|
Input consists of several datasets. Each dataset has an integer n (1 ≤ n ≤
999,999) in a line.
The number of datasets is less than or equal to 30.
|
A = [
960131,
960137,
960139,
960151,
960173,
960191,
960199,
960217,
960229,
960251,
960259,
960293,
960299,
960329,
960331,
960341,
960353,
960373,
960383,
960389,
960419,
960467,
960493,
960497,
960499,
960521,
960523,
960527,
960569,
960581,
960587,
960593,
960601,
960637,
960643,
960647,
960649,
960667,
960677,
960691,
960703,
960709,
960737,
960763,
960793,
960803,
960809,
960829,
960833,
960863,
960889,
960931,
960937,
960941,
960961,
960977,
960983,
960989,
960991,
961003,
961021,
961033,
961063,
961067,
961069,
961073,
999149,
999169,
999181,
999199,
999217,
999221,
999233,
999239,
999269,
999287,
999307,
999329,
999331,
999359,
999371,
999377,
999389,
999431,
999433,
999437,
999451,
999491,
999499,
999521,
999529,
999541,
999553,
999563,
999599,
999611,
999613,
999623,
999631,
999653,
999667,
999671,
999683,
999721,
999727,
999749,
999763,
999769,
999773,
999809,
999853,
999863,
999883,
999907,
999917,
999931,
999953,
999959,
999961,
999979,
999983,
]
while True:
try:
n = int(input())
print(A)
except:
break
|
Prime Number
Write a program which reads an integer n and prints the number of prime
numbers which are less than or equal to n. A prime number is a natural number
which has exactly two distinct natural number divisors: 1 and itself. For
example, the first four prime numbers are: 2, 3, 5 and 7.
|
[{"input": "3\n 11", "output": "2\n 5"}]
|
If there exists an integer i satisfying the following condition, print the
minimum such i; otherwise, print `-1`.
* * *
|
s891847823
|
Accepted
|
p02937
|
Input is given from Standard Input in the following format:
s
t
|
# -*- coding: utf-8 -*-
import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline
INF = 2**62 - 1
def read_int():
return int(buff_readline())
def read_int_n():
return list(map(int, buff_readline().split()))
def read_float():
return float(buff_readline())
def read_float_n():
return list(map(float, buff_readline().split()))
def read_str():
return readline().strip()
def read_str_n():
return readline().strip().split()
def error_print(*args):
print(*args, file=sys.stderr)
def mt(f):
import time
def wrap(*args, **kwargs):
s = time.time()
ret = f(*args, **kwargs)
e = time.time()
error_print(e - s, "sec")
return ret
return wrap
class Mod:
def __init__(self, m):
self.m = m
def add(self, a, b):
return (a + b) % self.m
def sub(self, a, b):
return (a - b) % self.m
def mul(self, a, b):
return ((a % self.m) * (b % self.m)) % self.m
def div(self, a, b):
return self.mul(a, pow(b, self.m - 2, self.m))
def pow(self, a, b):
return pow(a, b, self.m)
@mt
def slv(S, T):
if len(set(c for c in T) - set(c for c in S)) > 0:
return -1
from collections import defaultdict
si = defaultdict(list)
for i, c in enumerate(S):
si[c].append(i)
ans = 0
ci = 0
from bisect import bisect_left
for i, c in enumerate(T):
j = bisect_left(si[c], ci)
if j == len(si[c]):
j = 0
ans += 1
ci = si[c][j] + 1
return (ans) * len(S) + ci
def main():
S = read_str()
T = read_str()
print(slv(S, T))
if __name__ == "__main__":
main()
|
Statement
Given are two strings s and t consisting of lowercase English letters.
Determine if there exists an integer i satisfying the following condition, and
find the minimum such i if it exists.
* Let s' be the concatenation of 10^{100} copies of s. t is a subsequence of the string {s'}_1{s'}_2\ldots{s'}_i (the first i characters in s').
|
[{"input": "contest\n son", "output": "10\n \n\nt = `son` is a subsequence of the string `contestcon` (the first 10 characters\nin s' = `contestcontestcontest...`), so i = 10 satisfies the condition.\n\nOn the other hand, t is not a subsequence of the string `contestco` (the first\n9 characters in s'), so i = 9 does not satisfy the condition.\n\nSimilarly, any integer less than 9 does not satisfy the condition, either.\nThus, the minimum integer i satisfying the condition is 10.\n\n* * *"}, {"input": "contest\n programming", "output": "-1\n \n\nt = `programming` is not a substring of s' = `contestcontestcontest...`. Thus,\nthere is no integer i satisfying the condition.\n\n* * *"}, {"input": "contest\n sentence", "output": "33\n \n\nNote that the answer may not fit into a 32-bit integer type, though we cannot\nput such a case here."}]
|
If there exists an integer i satisfying the following condition, print the
minimum such i; otherwise, print `-1`.
* * *
|
s348414936
|
Wrong Answer
|
p02937
|
Input is given from Standard Input in the following format:
s
t
|
# tempt
s = input()
t = input()
ans = 0
cnt = [] * 26
|
Statement
Given are two strings s and t consisting of lowercase English letters.
Determine if there exists an integer i satisfying the following condition, and
find the minimum such i if it exists.
* Let s' be the concatenation of 10^{100} copies of s. t is a subsequence of the string {s'}_1{s'}_2\ldots{s'}_i (the first i characters in s').
|
[{"input": "contest\n son", "output": "10\n \n\nt = `son` is a subsequence of the string `contestcon` (the first 10 characters\nin s' = `contestcontestcontest...`), so i = 10 satisfies the condition.\n\nOn the other hand, t is not a subsequence of the string `contestco` (the first\n9 characters in s'), so i = 9 does not satisfy the condition.\n\nSimilarly, any integer less than 9 does not satisfy the condition, either.\nThus, the minimum integer i satisfying the condition is 10.\n\n* * *"}, {"input": "contest\n programming", "output": "-1\n \n\nt = `programming` is not a substring of s' = `contestcontestcontest...`. Thus,\nthere is no integer i satisfying the condition.\n\n* * *"}, {"input": "contest\n sentence", "output": "33\n \n\nNote that the answer may not fit into a 32-bit integer type, though we cannot\nput such a case here."}]
|
If there exists an integer i satisfying the following condition, print the
minimum such i; otherwise, print `-1`.
* * *
|
s557599568
|
Runtime Error
|
p02937
|
Input is given from Standard Input in the following format:
s
t
|
import sys
sys.setrecursionlimit(100000000)
class Graph:
def __init__(self, N):
self.V = {}
self.E = {}
for i in range(N):
self.V[i + 1] = 0
self.E[i + 1] = {}
def add_edge(self, u, v, w):
self.E[u][v] = w
def calc(N, G):
result = [0] * N
def walk(u, current_value=0):
current_value = G.V[u] + current_value
result[u - 1] = current_value
for v in G.E[u]:
walk(v, current_value)
walk(1, 0)
return result
N, Q = map(int, input().strip().split())
G = Graph(N)
for _ in range(N - 1):
a, b = map(int, input().strip().split())
G.add_edge(a, b, 0)
for _ in range(Q):
p, x = map(int, input().strip().split())
G.V[p] += x
result = calc(N, G)
print(" ".join(map(str, result)))
|
Statement
Given are two strings s and t consisting of lowercase English letters.
Determine if there exists an integer i satisfying the following condition, and
find the minimum such i if it exists.
* Let s' be the concatenation of 10^{100} copies of s. t is a subsequence of the string {s'}_1{s'}_2\ldots{s'}_i (the first i characters in s').
|
[{"input": "contest\n son", "output": "10\n \n\nt = `son` is a subsequence of the string `contestcon` (the first 10 characters\nin s' = `contestcontestcontest...`), so i = 10 satisfies the condition.\n\nOn the other hand, t is not a subsequence of the string `contestco` (the first\n9 characters in s'), so i = 9 does not satisfy the condition.\n\nSimilarly, any integer less than 9 does not satisfy the condition, either.\nThus, the minimum integer i satisfying the condition is 10.\n\n* * *"}, {"input": "contest\n programming", "output": "-1\n \n\nt = `programming` is not a substring of s' = `contestcontestcontest...`. Thus,\nthere is no integer i satisfying the condition.\n\n* * *"}, {"input": "contest\n sentence", "output": "33\n \n\nNote that the answer may not fit into a 32-bit integer type, though we cannot\nput such a case here."}]
|
If there exists an integer i satisfying the following condition, print the
minimum such i; otherwise, print `-1`.
* * *
|
s589696025
|
Wrong Answer
|
p02937
|
Input is given from Standard Input in the following format:
s
t
|
s = list(str(input()))
s_pri = s.copy()
m = len(s)
t = list(str(input()))
n = len(t)
ans = 0
k = 0
while k < n:
tk = t[k]
if not tk in s:
print("-1")
break
else:
if k != n - 1 and tk in s_pri:
a = s_pri.index(tk) + 1
del s_pri[:a]
elif k != n - 1 and not tk in s_pri:
ans += m
s_pri = s.copy()
a = s_pri.index(tk) + 1
del s_pri[:a]
elif k == n - 1:
if tk in s_pri:
a = s_pri.index(tk) + 1
m_pri = m - len(s_pri) + a
ans += m_pri
else:
m_pri = s.index(tk) + 1
ans += m_pri
print(ans)
k += 1
|
Statement
Given are two strings s and t consisting of lowercase English letters.
Determine if there exists an integer i satisfying the following condition, and
find the minimum such i if it exists.
* Let s' be the concatenation of 10^{100} copies of s. t is a subsequence of the string {s'}_1{s'}_2\ldots{s'}_i (the first i characters in s').
|
[{"input": "contest\n son", "output": "10\n \n\nt = `son` is a subsequence of the string `contestcon` (the first 10 characters\nin s' = `contestcontestcontest...`), so i = 10 satisfies the condition.\n\nOn the other hand, t is not a subsequence of the string `contestco` (the first\n9 characters in s'), so i = 9 does not satisfy the condition.\n\nSimilarly, any integer less than 9 does not satisfy the condition, either.\nThus, the minimum integer i satisfying the condition is 10.\n\n* * *"}, {"input": "contest\n programming", "output": "-1\n \n\nt = `programming` is not a substring of s' = `contestcontestcontest...`. Thus,\nthere is no integer i satisfying the condition.\n\n* * *"}, {"input": "contest\n sentence", "output": "33\n \n\nNote that the answer may not fit into a 32-bit integer type, though we cannot\nput such a case here."}]
|
Print the maximum possible area of the rectangle. If no rectangle can be
formed, print 0.
* * *
|
s455216649
|
Runtime Error
|
p03625
|
Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N
|
def resolve():
n=int(input())
a=list(map(int,input().split()))
s=list(set(a))[::-1]
l=[0]*3
k=0
for i in s:
if a.count(i)>=4:
l[k],l[k+1]=i,i
k+=2
elif a.count(i)>=2:
l[k]=i
k+=1
if k>1:
break
print(l[0]*l[1])
resolve():
|
Statement
We have N sticks with negligible thickness. The length of the i-th stick is
A_i.
Snuke wants to select four different sticks from these sticks and form a
rectangle (including a square), using the sticks as its sides. Find the
maximum possible area of the rectangle.
|
[{"input": "6\n 3 1 2 4 2 1", "output": "2\n \n\n1 \\times 2 rectangle can be formed.\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "0\n \n\nNo rectangle can be formed.\n\n* * *"}, {"input": "10\n 3 3 3 3 4 4 4 5 5 5", "output": "20"}]
|
Print the maximum possible area of the rectangle. If no rectangle can be
formed, print 0.
* * *
|
s356646614
|
Runtime Error
|
p03625
|
Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N
|
from sys import stdin
input = stdin.readline
def main():
n = int(input())
a = list(map(int, input().split()))
if 4 <= n and n <= 10**5:
for i in a:
if not (1 <= i and i <= 10**9 and type(i) == int:
return
j = [x for x in a if a.count(x) > 1]
j.sort(reverse = True)
if len(j) < 4:
print(0)
return
print(j[0]*j[2])
if __name__ == "__main__":
main()
|
Statement
We have N sticks with negligible thickness. The length of the i-th stick is
A_i.
Snuke wants to select four different sticks from these sticks and form a
rectangle (including a square), using the sticks as its sides. Find the
maximum possible area of the rectangle.
|
[{"input": "6\n 3 1 2 4 2 1", "output": "2\n \n\n1 \\times 2 rectangle can be formed.\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "0\n \n\nNo rectangle can be formed.\n\n* * *"}, {"input": "10\n 3 3 3 3 4 4 4 5 5 5", "output": "20"}]
|
Print the maximum possible area of the rectangle. If no rectangle can be
formed, print 0.
* * *
|
s524580607
|
Wrong Answer
|
p03625
|
Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N
|
from sys import stdin
from itertools import groupby
n = int(stdin.readline().rstrip())
li = list(map(int, stdin.readline().rstrip().split()))
li.sort(reverse=True)
lin = []
for key, value in groupby(li):
lin.append((key, len(list(value))))
mae = 0
ato = 0
for i in lin:
if i[1] >= 2 and mae == 0:
mae = i[0]
elif i[1] >= 2 and ato == 0:
ato = i[0]
print(mae * ato)
|
Statement
We have N sticks with negligible thickness. The length of the i-th stick is
A_i.
Snuke wants to select four different sticks from these sticks and form a
rectangle (including a square), using the sticks as its sides. Find the
maximum possible area of the rectangle.
|
[{"input": "6\n 3 1 2 4 2 1", "output": "2\n \n\n1 \\times 2 rectangle can be formed.\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "0\n \n\nNo rectangle can be formed.\n\n* * *"}, {"input": "10\n 3 3 3 3 4 4 4 5 5 5", "output": "20"}]
|
Print the maximum possible area of the rectangle. If no rectangle can be
formed, print 0.
* * *
|
s823851106
|
Runtime Error
|
p03625
|
Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N
|
#Make a Rectangle
N = int(input())
A = list(map(int, input().split())
a = sorted(A, reverse=True)
b = []
i = 0
while i<N-2:
if ( a[i]==a[i+1] ):
b+=[a[i]]
i+=2
else:
i+=1
if (len(b)>=2):
break
if (len(b)<2):
print(0)
else:
print(b[0]*b[1])
|
Statement
We have N sticks with negligible thickness. The length of the i-th stick is
A_i.
Snuke wants to select four different sticks from these sticks and form a
rectangle (including a square), using the sticks as its sides. Find the
maximum possible area of the rectangle.
|
[{"input": "6\n 3 1 2 4 2 1", "output": "2\n \n\n1 \\times 2 rectangle can be formed.\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "0\n \n\nNo rectangle can be formed.\n\n* * *"}, {"input": "10\n 3 3 3 3 4 4 4 5 5 5", "output": "20"}]
|
Print the maximum possible area of the rectangle. If no rectangle can be
formed, print 0.
* * *
|
s022081222
|
Runtime Error
|
p03625
|
Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N
|
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;
int main() {
int N;
int A[100000];
cin >> N;
for(int i = 0; i < N; i++)
cin >> A[i];
}
|
Statement
We have N sticks with negligible thickness. The length of the i-th stick is
A_i.
Snuke wants to select four different sticks from these sticks and form a
rectangle (including a square), using the sticks as its sides. Find the
maximum possible area of the rectangle.
|
[{"input": "6\n 3 1 2 4 2 1", "output": "2\n \n\n1 \\times 2 rectangle can be formed.\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "0\n \n\nNo rectangle can be formed.\n\n* * *"}, {"input": "10\n 3 3 3 3 4 4 4 5 5 5", "output": "20"}]
|
Print the maximum possible area of the rectangle. If no rectangle can be
formed, print 0.
* * *
|
s363737802
|
Runtime Error
|
p03625
|
Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N
|
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
ac = Counter(a)
cur_a = 0
cur_c = 0
res = 0
for a,c in ac.items():
if c < 2:
break
if c >= 4:
res = max(res,a*a)
if cur_c == c
res = max(res,cur_a*a)
cur_a = max(cur_a,a)
else:
cur_a = a
cur_c = c
print(res)
|
Statement
We have N sticks with negligible thickness. The length of the i-th stick is
A_i.
Snuke wants to select four different sticks from these sticks and form a
rectangle (including a square), using the sticks as its sides. Find the
maximum possible area of the rectangle.
|
[{"input": "6\n 3 1 2 4 2 1", "output": "2\n \n\n1 \\times 2 rectangle can be formed.\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "0\n \n\nNo rectangle can be formed.\n\n* * *"}, {"input": "10\n 3 3 3 3 4 4 4 5 5 5", "output": "20"}]
|
Print the maximum possible area of the rectangle. If no rectangle can be
formed, print 0.
* * *
|
s290468136
|
Runtime Error
|
p03625
|
Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N
|
N = input()
A = list(map(int, input().split()))
A.sort(reverse=True)
now = A[0]
tateyoko = [0, 0]
count = 0
nowflag = False
for i in range(1, N):
if (A[i] == now) and !nowflag:
tateyoko[count] = now
count += 1
nowflag = True
else:
nowflag = False
if count == 2:
break
now = A[i]
print(tateyoko[0] * tateyoko[1])
|
Statement
We have N sticks with negligible thickness. The length of the i-th stick is
A_i.
Snuke wants to select four different sticks from these sticks and form a
rectangle (including a square), using the sticks as its sides. Find the
maximum possible area of the rectangle.
|
[{"input": "6\n 3 1 2 4 2 1", "output": "2\n \n\n1 \\times 2 rectangle can be formed.\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "0\n \n\nNo rectangle can be formed.\n\n* * *"}, {"input": "10\n 3 3 3 3 4 4 4 5 5 5", "output": "20"}]
|
Print the maximum possible area of the rectangle. If no rectangle can be
formed, print 0.
* * *
|
s251897399
|
Runtime Error
|
p03625
|
Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N
|
a = int(input())
ar = list(map(int,input().split(" ")))
br = sorted(set(ar))
cr = []
for b in br:
if ar.count(b) >= 2:
cr.append(b)
if len(cr) == 0:
print(0)
else:
if ar.count(max(cr)) >= 4:
print(max(cr) ** 2)
else:
dr = sorted(cr,reverse=True)
print(dr[0] * dr[1])
|
Statement
We have N sticks with negligible thickness. The length of the i-th stick is
A_i.
Snuke wants to select four different sticks from these sticks and form a
rectangle (including a square), using the sticks as its sides. Find the
maximum possible area of the rectangle.
|
[{"input": "6\n 3 1 2 4 2 1", "output": "2\n \n\n1 \\times 2 rectangle can be formed.\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "0\n \n\nNo rectangle can be formed.\n\n* * *"}, {"input": "10\n 3 3 3 3 4 4 4 5 5 5", "output": "20"}]
|
Print the maximum possible area of the rectangle. If no rectangle can be
formed, print 0.
* * *
|
s722400280
|
Wrong Answer
|
p03625
|
Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N
|
print(0)
|
Statement
We have N sticks with negligible thickness. The length of the i-th stick is
A_i.
Snuke wants to select four different sticks from these sticks and form a
rectangle (including a square), using the sticks as its sides. Find the
maximum possible area of the rectangle.
|
[{"input": "6\n 3 1 2 4 2 1", "output": "2\n \n\n1 \\times 2 rectangle can be formed.\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "0\n \n\nNo rectangle can be formed.\n\n* * *"}, {"input": "10\n 3 3 3 3 4 4 4 5 5 5", "output": "20"}]
|
Print the maximum possible area of the rectangle. If no rectangle can be
formed, print 0.
* * *
|
s206370334
|
Runtime Error
|
p03625
|
Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N
|
_=input()
A=list(map(int,input().split()))
B=list(set(A))
ans=-1
B=sorted(B)[::-1]
for i in B:
if A.count(i) >=4:
print(i**2)
else:
A.count(i) >= 2:
if ans==-1:
ans=i
else:
print(ans*i)
exit()
print(0)
|
Statement
We have N sticks with negligible thickness. The length of the i-th stick is
A_i.
Snuke wants to select four different sticks from these sticks and form a
rectangle (including a square), using the sticks as its sides. Find the
maximum possible area of the rectangle.
|
[{"input": "6\n 3 1 2 4 2 1", "output": "2\n \n\n1 \\times 2 rectangle can be formed.\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "0\n \n\nNo rectangle can be formed.\n\n* * *"}, {"input": "10\n 3 3 3 3 4 4 4 5 5 5", "output": "20"}]
|
Print the maximum possible area of the rectangle. If no rectangle can be
formed, print 0.
* * *
|
s261375739
|
Runtime Error
|
p03625
|
Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N
|
n=int(input()) a=list(map(int,input().split(' '))) x=0 y=0 a.sort() a.reverse() for i in range(len(a)-1): if a[i]==a[i+1]: x=a[i] p=i+1 break if x!=0: for i in range((p+1),len(a)-1): if a[i]==a[i+1]: y=a[i] break print(x*y)
|
Statement
We have N sticks with negligible thickness. The length of the i-th stick is
A_i.
Snuke wants to select four different sticks from these sticks and form a
rectangle (including a square), using the sticks as its sides. Find the
maximum possible area of the rectangle.
|
[{"input": "6\n 3 1 2 4 2 1", "output": "2\n \n\n1 \\times 2 rectangle can be formed.\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "0\n \n\nNo rectangle can be formed.\n\n* * *"}, {"input": "10\n 3 3 3 3 4 4 4 5 5 5", "output": "20"}]
|
Print the maximum possible area of the rectangle. If no rectangle can be
formed, print 0.
* * *
|
s802895998
|
Runtime Error
|
p03625
|
Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N
|
M = int(input())
A = list(map(int,input().split()))
B = [0]*(M+1)
C = [0]*2
D = [0]*2
for i in range(len(A)):
B[ A[i] ] += 1 # カウント
for i in range(len(B)):
# 一個しかなかったら条件を満たさないのでするー
if B[i] < 2:
continue
# 2個以上あれば長方形にスタック
C.append(i)
# 4個以上あれば正方形にスタック
if B[i] >= 4:
D.append(i)
# C を降順でソート
C = sorted(C, reverse=True)
rect = C[0] * C[1]
s = max(D)
square = s * s
print(max(rect,square))
|
Statement
We have N sticks with negligible thickness. The length of the i-th stick is
A_i.
Snuke wants to select four different sticks from these sticks and form a
rectangle (including a square), using the sticks as its sides. Find the
maximum possible area of the rectangle.
|
[{"input": "6\n 3 1 2 4 2 1", "output": "2\n \n\n1 \\times 2 rectangle can be formed.\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "0\n \n\nNo rectangle can be formed.\n\n* * *"}, {"input": "10\n 3 3 3 3 4 4 4 5 5 5", "output": "20"}]
|
Print the maximum possible area of the rectangle. If no rectangle can be
formed, print 0.
* * *
|
s448644078
|
Runtime Error
|
p03625
|
Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N
|
from collections import defaultdict
N = int(input())
A = sorted([int(i) for i in input().split()], reverse=True)
A_dict = defaultdict(lambda:0)
for a in A:
A_dict[a] += 1
key1 = 0
key2 = 0
for key in A_dict.keys():
if key2 > 0:
break
if A_dict[key] > 3:
if key1 == 0;
key1 = key
if key2 == 0;
key2 = key
elif A_dict[key] > 1:
if key1 > 0:
key2 = key
else:
key1 = key
print(key1*key2)
|
Statement
We have N sticks with negligible thickness. The length of the i-th stick is
A_i.
Snuke wants to select four different sticks from these sticks and form a
rectangle (including a square), using the sticks as its sides. Find the
maximum possible area of the rectangle.
|
[{"input": "6\n 3 1 2 4 2 1", "output": "2\n \n\n1 \\times 2 rectangle can be formed.\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "0\n \n\nNo rectangle can be formed.\n\n* * *"}, {"input": "10\n 3 3 3 3 4 4 4 5 5 5", "output": "20"}]
|
Print the maximum possible area of the rectangle. If no rectangle can be
formed, print 0.
* * *
|
s781134151
|
Runtime Error
|
p03625
|
Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N
|
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<char,char> PCC;
typedef pair<ll,ll> PLL;
typedef pair<char,int> PCI;
typedef pair<int,char> PIC;
typedef pair<ll,int> PLI;
typedef pair<int,ll> PIL;
typedef pair<ll,char> PLC;
typedef pair<char,ll> PCL;
inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}
int main(void){
SPEEDUP
cout << setprecision(15);
int N;cin >> N;
ll max1,max2;
map<ll,int> mp;
max1 = max2 = 0;
rep(i,N){
ll x;cin >> x;
if(mp.count(x) && mp[x]&1){
if(x>max1){
max2 = max1;
max1 = x;
}else if(x>max2) max2 = x;
}else mp[x] = 0;
++mp[x];
}
cout << max1*max2 << endl;
return 0;
}
|
Statement
We have N sticks with negligible thickness. The length of the i-th stick is
A_i.
Snuke wants to select four different sticks from these sticks and form a
rectangle (including a square), using the sticks as its sides. Find the
maximum possible area of the rectangle.
|
[{"input": "6\n 3 1 2 4 2 1", "output": "2\n \n\n1 \\times 2 rectangle can be formed.\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "0\n \n\nNo rectangle can be formed.\n\n* * *"}, {"input": "10\n 3 3 3 3 4 4 4 5 5 5", "output": "20"}]
|
Print the maximum possible area of the rectangle. If no rectangle can be
formed, print 0.
* * *
|
s689174648
|
Runtime Error
|
p03625
|
Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N
|
import sys
import math
import collections
import itertools
import array
import inspect
# Set max recursion limit
sys.setrecursionlimit(1000000)
# Debug output
def chkprint(*args):
names = {
id(v): k
for k, v in inspect.currentframe().f_back.f_locals.items()
}
print(', '.join(
names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))
# Binary converter
def to_bin(x):
return bin(x)[2:]
def li_input():
return [int(_) for _ in input().split()]
def gcd(n, m):
if n % m == 0:
return m
else:
return gcd(m, n % m)
def gcd_list(L):
v = L[0]
for i in range(1, len(L)):
v = gcd(v, L[i])
return v
def lcm(n, m):
return (n * m) // gcd(n, m)
def lcm_list(L):
v = L[0]
for i in range(1, len(L)):
v = lcm(v, L[i])
return v
# Width First Search (+ Distance)
def wfs_d(D, N, K):
"""
D: 隣接行列(距離付き)
N: ノード数
K: 始点ノード
"""
dfk = [-1] * (N + 1)
dfk[K] = 0
cps = [(K, 0)]
r = [False] * (N + 1)
r[K] = True
while len(cps) != 0:
n_cps = []
for cp, cd in cps:
for i, dfcp in enumerate(D[cp]):
if dfcp != -1 and not r[i]:
dfk[i] = cd + dfcp
n_cps.append((i, cd + dfcp))
r[i] = True
cps = n_cps[:]
return dfk
# Depth First Search (+Distance)
def dfs_d(v, pre, dist):
"""
v: 現在のノード
pre: 1つ前のノード
dist: 現在の距離
以下は別途用意する
D: 隣接リスト(行列ではない)
D_dfs_d: dfs_d関数で用いる,始点ノードから見た距離リスト
"""
global D
global D_dfs_d
D_dfs_d[v] = dist
for next_v, d in D[v]:
if next_v != pre:
dfs_d(next_v, v, dist + d)
return
def sigma(N):
ans = 0
for i in range(1, N + 1):
ans += i
return ans
def comb(n, r):
if n - r < r: r = n - r
if r == 0: return 1
if r == 1: return n
numerator = [n - r + k + 1 for k in range(r)]
denominator = [k + 1 for k in range(r)]
for p in range(2, r + 1):
pivot = denominator[p - 1]
if pivot > 1:
offset = (n - r) % p
for k in range(p - 1, r, p):
numerator[k - offset] /= pivot
denominator[k] /= pivot
result = 1
for k in range(r):
if numerator[k] > 1:
result *= int(numerator[k])
return result
def bisearch(L, target):
low = 0
high = len(L) - 1
while low <= high:
mid = (low + high) // 2
guess = L[mid]
if guess == target:
return True
elif guess < target:
low = mid + 1
elif guess > target:
high = mid - 1
if guess != target:
return False
# --------------------------------------------
dp = None
def main():
N = int(input())
A = sorted(li_input(), reverse=1)
D = collections.defaultdict(lambda: 0)
E = []
for a in A:
D[a] += 1
for d in D.keys():
for i in range(max(2, D[d] // 2))
E.append(d)
if len(E) >= 2:
E.sort(reverse=True)
print(E[0] * E[1])
else:
print(0)
main()
|
Statement
We have N sticks with negligible thickness. The length of the i-th stick is
A_i.
Snuke wants to select four different sticks from these sticks and form a
rectangle (including a square), using the sticks as its sides. Find the
maximum possible area of the rectangle.
|
[{"input": "6\n 3 1 2 4 2 1", "output": "2\n \n\n1 \\times 2 rectangle can be formed.\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "0\n \n\nNo rectangle can be formed.\n\n* * *"}, {"input": "10\n 3 3 3 3 4 4 4 5 5 5", "output": "20"}]
|
Print the maximum possible area of the rectangle. If no rectangle can be
formed, print 0.
* * *
|
s840496721
|
Runtime Error
|
p03625
|
Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N
|
N = int(input())
A = list(map(int, input().split()))
bar_length_count = dict()
for a in A:
bar_length_count[a] = bar_length_count.get(a, 0) + 1
for val in bar_length_count.values():
pass
count_at_least_2 = 0
for val in bar_length_count.values():
if val >= 2:
if val >= 4:
count_at_least_2 += 2
else:
count_at_least_2 += 1
if count_at_least_2 < 2:
import sys
print(0)
sys.exit(0)
else:
bar_length_count = sorted([(k, v) for bar_length_count.items() if v >= 2], reverse=True)
if bar_length_count[0][1] >= 4:
print(bar_length_count[0][0]**2)
else:
print(bar_length_count[0][0]*bar_length_count[1][0])
|
Statement
We have N sticks with negligible thickness. The length of the i-th stick is
A_i.
Snuke wants to select four different sticks from these sticks and form a
rectangle (including a square), using the sticks as its sides. Find the
maximum possible area of the rectangle.
|
[{"input": "6\n 3 1 2 4 2 1", "output": "2\n \n\n1 \\times 2 rectangle can be formed.\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "0\n \n\nNo rectangle can be formed.\n\n* * *"}, {"input": "10\n 3 3 3 3 4 4 4 5 5 5", "output": "20"}]
|
Print the maximum possible area of the rectangle. If no rectangle can be
formed, print 0.
* * *
|
s069277149
|
Runtime Error
|
p03625
|
Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N
|
import math
import collections
N = int(input())
A = [int(input()) for x in range(N)]
c = collections.Counter(A)
#print(c)
aaa = []
for i in (reversed(sorted(A))):
#print(i)
#print(">>",c[i])
#print()
if c[i] > 1:
c[i]-=2
aaa.append(i)
if len(aaa) == 2:
break
if len(aaa) < 2:
print(0)
else:
print(aaa[0]*aaa[1])3
|
Statement
We have N sticks with negligible thickness. The length of the i-th stick is
A_i.
Snuke wants to select four different sticks from these sticks and form a
rectangle (including a square), using the sticks as its sides. Find the
maximum possible area of the rectangle.
|
[{"input": "6\n 3 1 2 4 2 1", "output": "2\n \n\n1 \\times 2 rectangle can be formed.\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "0\n \n\nNo rectangle can be formed.\n\n* * *"}, {"input": "10\n 3 3 3 3 4 4 4 5 5 5", "output": "20"}]
|
Print the maximum possible area of the rectangle. If no rectangle can be
formed, print 0.
* * *
|
s365595496
|
Runtime Error
|
p03625
|
Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N
|
n = int(input())
a = list(map(int,input().split()))
a_sort = list(reversed(list(sorted(a))))
amax = max(a_sort)
if a_sort.count(amax) >3:
print(amax ** 2)
else:
one = 0
two = 0
for i in a_sort:
if a_sort.count(i) > 1 and one = 0 and two = 0:
one = i
elif a_sort.count(i) > 1 and one > 0 and two = 0:
two = i
else:
break
print(one*two)
|
Statement
We have N sticks with negligible thickness. The length of the i-th stick is
A_i.
Snuke wants to select four different sticks from these sticks and form a
rectangle (including a square), using the sticks as its sides. Find the
maximum possible area of the rectangle.
|
[{"input": "6\n 3 1 2 4 2 1", "output": "2\n \n\n1 \\times 2 rectangle can be formed.\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "0\n \n\nNo rectangle can be formed.\n\n* * *"}, {"input": "10\n 3 3 3 3 4 4 4 5 5 5", "output": "20"}]
|
Print the maximum possible area of the rectangle. If no rectangle can be
formed, print 0.
* * *
|
s928686315
|
Runtime Error
|
p03625
|
Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N
|
line1 = 0
line2 = 0
n = int(input())
lines = list(map(int,input().split()))
lines.sort()
mx1,mx2 = 0,0
temp = 0
streak = 0
for l in lines:
if l != temp:
temp = l
streak = 0
elif l == temp and streak = 0:
streak += 1
elif l == temp and streak == 1 and l > mx1:
mx2 = mx1
mx1 = l
streak = 0
elif l == temp and streak == 1 and l > mx2:
mx2 = l
streak = 0
print(mx1 * mx2)
|
Statement
We have N sticks with negligible thickness. The length of the i-th stick is
A_i.
Snuke wants to select four different sticks from these sticks and form a
rectangle (including a square), using the sticks as its sides. Find the
maximum possible area of the rectangle.
|
[{"input": "6\n 3 1 2 4 2 1", "output": "2\n \n\n1 \\times 2 rectangle can be formed.\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "0\n \n\nNo rectangle can be formed.\n\n* * *"}, {"input": "10\n 3 3 3 3 4 4 4 5 5 5", "output": "20"}]
|
Print the maximum possible area of the rectangle. If no rectangle can be
formed, print 0.
* * *
|
s297397996
|
Runtime Error
|
p03625
|
Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N
|
n = int(input())
vals = list(map(int, input().split()))
d= {}
s = [0, 0]
for i in range(n):
if(vals[i] in d.keys()):
d[vals[i]] += 1
else:
d[vals[i]] = 1
for i in d.keys():
if(d[i] >= 4):
s.append(i)
s.append(i)
elif(d[i] >= 2):
s.append(i)
s.sort()
print(s[-1]*s[-2])
|
Statement
We have N sticks with negligible thickness. The length of the i-th stick is
A_i.
Snuke wants to select four different sticks from these sticks and form a
rectangle (including a square), using the sticks as its sides. Find the
maximum possible area of the rectangle.
|
[{"input": "6\n 3 1 2 4 2 1", "output": "2\n \n\n1 \\times 2 rectangle can be formed.\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "0\n \n\nNo rectangle can be formed.\n\n* * *"}, {"input": "10\n 3 3 3 3 4 4 4 5 5 5", "output": "20"}]
|
Print the maximum possible area of the rectangle. If no rectangle can be
formed, print 0.
* * *
|
s789683201
|
Runtime Error
|
p03625
|
Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N
|
k = int(input())
vals = list(map(int, input().split()))
d= {}
a = [0, 0]
for i in range(k):
if(vals[i] in d.keys()):
d[vals[i]] += 1
else:
d[vals[i]] = 1
for i in d.keys():
if(d[i] >= 4):
a.append(i)
a.append(i)
elif(d[i] >= 2):
a.append(i)
a.sort()
print(a[-1]*a[-2])
|
Statement
We have N sticks with negligible thickness. The length of the i-th stick is
A_i.
Snuke wants to select four different sticks from these sticks and form a
rectangle (including a square), using the sticks as its sides. Find the
maximum possible area of the rectangle.
|
[{"input": "6\n 3 1 2 4 2 1", "output": "2\n \n\n1 \\times 2 rectangle can be formed.\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "0\n \n\nNo rectangle can be formed.\n\n* * *"}, {"input": "10\n 3 3 3 3 4 4 4 5 5 5", "output": "20"}]
|
Print the maximum possible area of the rectangle. If no rectangle can be
formed, print 0.
* * *
|
s281031715
|
Accepted
|
p03625
|
Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N
|
import sys
stdin = sys.stdin
def li():
return map(int, stdin.readline().split())
def li_():
return map(lambda x: int(x) - 1, stdin.readline().split())
def lf():
return map(float, stdin.readline().split())
def ls():
return stdin.readline().split()
def ns():
return stdin.readline().rstrip()
def lc():
return list(ns())
def ni():
return int(stdin.readline())
def nf():
return float(stdin.readline())
from collections import Counter
n = ni()
a = list(li())
cnt = Counter(a)
lst = []
for k, v in cnt.items():
lst.append((k, v))
lst.sort(reverse=True)
first = 0
second = 0
for k, v in lst:
if v >= 4 and first == 0:
first = k
second = k
break
elif v >= 4:
second = k
break
elif v >= 2 and first != 0:
second = k
break
elif v >= 2:
first = k
print(first * second)
|
Statement
We have N sticks with negligible thickness. The length of the i-th stick is
A_i.
Snuke wants to select four different sticks from these sticks and form a
rectangle (including a square), using the sticks as its sides. Find the
maximum possible area of the rectangle.
|
[{"input": "6\n 3 1 2 4 2 1", "output": "2\n \n\n1 \\times 2 rectangle can be formed.\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "0\n \n\nNo rectangle can be formed.\n\n* * *"}, {"input": "10\n 3 3 3 3 4 4 4 5 5 5", "output": "20"}]
|
Print the maximum possible area of the rectangle. If no rectangle can be
formed, print 0.
* * *
|
s882131808
|
Runtime Error
|
p03625
|
Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N
|
n = input()
l = [int(x) for x in input().split()]
temp = list(set(x for x in l if l.count(x) > 1))
y = max(temp)
if l.count(y) > 3:
lar = sec = y
else:
lar = y
temp.remove(y)
sec = max(temp)
print(lar * sec)
|
Statement
We have N sticks with negligible thickness. The length of the i-th stick is
A_i.
Snuke wants to select four different sticks from these sticks and form a
rectangle (including a square), using the sticks as its sides. Find the
maximum possible area of the rectangle.
|
[{"input": "6\n 3 1 2 4 2 1", "output": "2\n \n\n1 \\times 2 rectangle can be formed.\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "0\n \n\nNo rectangle can be formed.\n\n* * *"}, {"input": "10\n 3 3 3 3 4 4 4 5 5 5", "output": "20"}]
|
Print the maximum possible area of the rectangle. If no rectangle can be
formed, print 0.
* * *
|
s690382947
|
Runtime Error
|
p03625
|
Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N
|
a = int(input())
ar = list(map(int, input().split(" ")))
br = sorted(set(ar))
cr = []
for b in br:
if ar.count(b) >= 2:
cr.append(b)
if ar.count(max(cr)) >= 4:
print(max(cr) ** 2)
else:
dr = sorted(cr, reverse=True)
print(dr[0] * dr[1])
|
Statement
We have N sticks with negligible thickness. The length of the i-th stick is
A_i.
Snuke wants to select four different sticks from these sticks and form a
rectangle (including a square), using the sticks as its sides. Find the
maximum possible area of the rectangle.
|
[{"input": "6\n 3 1 2 4 2 1", "output": "2\n \n\n1 \\times 2 rectangle can be formed.\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "0\n \n\nNo rectangle can be formed.\n\n* * *"}, {"input": "10\n 3 3 3 3 4 4 4 5 5 5", "output": "20"}]
|
Print the median of m.
* * *
|
s836046304
|
Wrong Answer
|
p03275
|
Input is given from Standard Input in the following format:
N
a_1 a_2 ... a_N
|
N = int(input())
array = list(map(int, input().split()))
array.insert(0, 0)
mid = int(N // 2 + 1)
length = N * (N + 1) / 2
middle = int(length // 2 + 1)
another = [[0, 0]]
count = 0
result = None
for i in range(1, N + 1):
if 2 * i - 1 <= N:
temp = 2 * i - 1
elif i == mid:
temp = N
elif i > mid:
temp = (N - i + 1) * 2
another.append([array[i], temp])
another.sort()
for i in range(1, N + 1):
count += another[i][1]
if count >= middle:
result = i
break
print(another[result][0])
|
Statement
We will define the **median** of a sequence b of length M, as follows:
* Let b' be the sequence obtained by sorting b in non-decreasing order. Then, the value of the (M / 2 + 1)-th element of b' is the median of b. Here, / is integer division, rounding down.
For example, the median of (10, 30, 20) is 20; the median of (10, 30, 20, 40)
is 30; the median of (10, 10, 10, 20, 30) is 10.
Snuke comes up with the following problem.
You are given a sequence a of length N. For each pair (l, r) (1 \leq l \leq r
\leq N), let m_{l, r} be the median of the contiguous subsequence (a_l, a_{l +
1}, ..., a_r) of a. We will list m_{l, r} for all pairs (l, r) to create a new
sequence m. Find the median of m.
|
[{"input": "3\n 10 30 20", "output": "30\n \n\nThe median of each contiguous subsequence of a is as follows:\n\n * The median of (10) is 10.\n * The median of (30) is 30.\n * The median of (20) is 20.\n * The median of (10, 30) is 30.\n * The median of (30, 20) is 30.\n * The median of (10, 30, 20) is 20.\n\nThus, m = (10, 30, 20, 30, 30, 20) and the median of m is 30.\n\n* * *"}, {"input": "1\n 10", "output": "10\n \n\n* * *"}, {"input": "10\n 5 9 5 9 8 9 3 5 4 3", "output": "8"}]
|
Print the median of m.
* * *
|
s156852901
|
Wrong Answer
|
p03275
|
Input is given from Standard Input in the following format:
N
a_1 a_2 ... a_N
|
n = int(input())
lst = list(map(int, input().split()))
ans = []
for i in range(1, n + 1):
for e in range(0, n + 1 - i):
ans.append(sorted(lst[e : e + i])[i // 2])
print(ans)
print(sorted(ans)[len(ans) // 2])
|
Statement
We will define the **median** of a sequence b of length M, as follows:
* Let b' be the sequence obtained by sorting b in non-decreasing order. Then, the value of the (M / 2 + 1)-th element of b' is the median of b. Here, / is integer division, rounding down.
For example, the median of (10, 30, 20) is 20; the median of (10, 30, 20, 40)
is 30; the median of (10, 10, 10, 20, 30) is 10.
Snuke comes up with the following problem.
You are given a sequence a of length N. For each pair (l, r) (1 \leq l \leq r
\leq N), let m_{l, r} be the median of the contiguous subsequence (a_l, a_{l +
1}, ..., a_r) of a. We will list m_{l, r} for all pairs (l, r) to create a new
sequence m. Find the median of m.
|
[{"input": "3\n 10 30 20", "output": "30\n \n\nThe median of each contiguous subsequence of a is as follows:\n\n * The median of (10) is 10.\n * The median of (30) is 30.\n * The median of (20) is 20.\n * The median of (10, 30) is 30.\n * The median of (30, 20) is 30.\n * The median of (10, 30, 20) is 20.\n\nThus, m = (10, 30, 20, 30, 30, 20) and the median of m is 30.\n\n* * *"}, {"input": "1\n 10", "output": "10\n \n\n* * *"}, {"input": "10\n 5 9 5 9 8 9 3 5 4 3", "output": "8"}]
|
Print the median of m.
* * *
|
s619910357
|
Runtime Error
|
p03275
|
Input is given from Standard Input in the following format:
N
a_1 a_2 ... a_N
|
N = int(input().rstrip())
num = [int(item) for item in input().split()]
new_m = []
for i in range(N):
idx = (i + 1) // 2
new_m.extend([sorted(num[j : j + i + 1])[idx] for j in range(N - i)])
new_m.sort()
print(new_m[N + N * N // 4])
|
Statement
We will define the **median** of a sequence b of length M, as follows:
* Let b' be the sequence obtained by sorting b in non-decreasing order. Then, the value of the (M / 2 + 1)-th element of b' is the median of b. Here, / is integer division, rounding down.
For example, the median of (10, 30, 20) is 20; the median of (10, 30, 20, 40)
is 30; the median of (10, 10, 10, 20, 30) is 10.
Snuke comes up with the following problem.
You are given a sequence a of length N. For each pair (l, r) (1 \leq l \leq r
\leq N), let m_{l, r} be the median of the contiguous subsequence (a_l, a_{l +
1}, ..., a_r) of a. We will list m_{l, r} for all pairs (l, r) to create a new
sequence m. Find the median of m.
|
[{"input": "3\n 10 30 20", "output": "30\n \n\nThe median of each contiguous subsequence of a is as follows:\n\n * The median of (10) is 10.\n * The median of (30) is 30.\n * The median of (20) is 20.\n * The median of (10, 30) is 30.\n * The median of (30, 20) is 30.\n * The median of (10, 30, 20) is 20.\n\nThus, m = (10, 30, 20, 30, 30, 20) and the median of m is 30.\n\n* * *"}, {"input": "1\n 10", "output": "10\n \n\n* * *"}, {"input": "10\n 5 9 5 9 8 9 3 5 4 3", "output": "8"}]
|
Print the median of m.
* * *
|
s848379131
|
Wrong Answer
|
p03275
|
Input is given from Standard Input in the following format:
N
a_1 a_2 ... a_N
|
# encoding: utf-8
N = int(input())
a = list(map(int, input().split()))
dict_count = {}
seq_list = []
# count num of submeds
for i, ai in enumerate(a):
# existing sequences
for seq in seq_list:
seq_temp = list(seq)
for k in range(len(seq)):
if ai <= seq[k]:
seq_temp.insert(k, ai)
break
else:
seq_temp.insert(-1, ai)
# update dict
submed = seq_temp[len(seq_temp) // 2]
if submed in dict_count.keys():
dict_count[str(submed)] += 1
else:
dict_count[str(submed)] = 1
# new sequence [ai]
seq_list.append([ai])
if ai in dict_count.keys():
dict_count[str(ai)] += 1
else:
dict_count[str(ai)] = 1
# ans
keys = sorted(dict_count.keys())
med = sum(dict_count.values()) // 2
med_temp = 0
for key in keys:
med_temp += dict_count[key]
if med_temp >= med:
print(key)
break
|
Statement
We will define the **median** of a sequence b of length M, as follows:
* Let b' be the sequence obtained by sorting b in non-decreasing order. Then, the value of the (M / 2 + 1)-th element of b' is the median of b. Here, / is integer division, rounding down.
For example, the median of (10, 30, 20) is 20; the median of (10, 30, 20, 40)
is 30; the median of (10, 10, 10, 20, 30) is 10.
Snuke comes up with the following problem.
You are given a sequence a of length N. For each pair (l, r) (1 \leq l \leq r
\leq N), let m_{l, r} be the median of the contiguous subsequence (a_l, a_{l +
1}, ..., a_r) of a. We will list m_{l, r} for all pairs (l, r) to create a new
sequence m. Find the median of m.
|
[{"input": "3\n 10 30 20", "output": "30\n \n\nThe median of each contiguous subsequence of a is as follows:\n\n * The median of (10) is 10.\n * The median of (30) is 30.\n * The median of (20) is 20.\n * The median of (10, 30) is 30.\n * The median of (30, 20) is 30.\n * The median of (10, 30, 20) is 20.\n\nThus, m = (10, 30, 20, 30, 30, 20) and the median of m is 30.\n\n* * *"}, {"input": "1\n 10", "output": "10\n \n\n* * *"}, {"input": "10\n 5 9 5 9 8 9 3 5 4 3", "output": "8"}]
|
Print the median of m.
* * *
|
s331851824
|
Wrong Answer
|
p03275
|
Input is given from Standard Input in the following format:
N
a_1 a_2 ... a_N
|
n = int(input())
c = 0
g = 0
bg = 0
hk = sum([i for i in range(1, n + 1)]) // 2 + 1
while c < n:
g += n - c
c += 1
if g >= hk:
z = hk - bg
q = list(map(int, input().split()))[z - 1 : z + c - 1]
print(sorted(q)[len(q) // 2])
break
bg = g
|
Statement
We will define the **median** of a sequence b of length M, as follows:
* Let b' be the sequence obtained by sorting b in non-decreasing order. Then, the value of the (M / 2 + 1)-th element of b' is the median of b. Here, / is integer division, rounding down.
For example, the median of (10, 30, 20) is 20; the median of (10, 30, 20, 40)
is 30; the median of (10, 10, 10, 20, 30) is 10.
Snuke comes up with the following problem.
You are given a sequence a of length N. For each pair (l, r) (1 \leq l \leq r
\leq N), let m_{l, r} be the median of the contiguous subsequence (a_l, a_{l +
1}, ..., a_r) of a. We will list m_{l, r} for all pairs (l, r) to create a new
sequence m. Find the median of m.
|
[{"input": "3\n 10 30 20", "output": "30\n \n\nThe median of each contiguous subsequence of a is as follows:\n\n * The median of (10) is 10.\n * The median of (30) is 30.\n * The median of (20) is 20.\n * The median of (10, 30) is 30.\n * The median of (30, 20) is 30.\n * The median of (10, 30, 20) is 20.\n\nThus, m = (10, 30, 20, 30, 30, 20) and the median of m is 30.\n\n* * *"}, {"input": "1\n 10", "output": "10\n \n\n* * *"}, {"input": "10\n 5 9 5 9 8 9 3 5 4 3", "output": "8"}]
|
Print the median of m.
* * *
|
s236459334
|
Wrong Answer
|
p03275
|
Input is given from Standard Input in the following format:
N
a_1 a_2 ... a_N
|
print(30)
|
Statement
We will define the **median** of a sequence b of length M, as follows:
* Let b' be the sequence obtained by sorting b in non-decreasing order. Then, the value of the (M / 2 + 1)-th element of b' is the median of b. Here, / is integer division, rounding down.
For example, the median of (10, 30, 20) is 20; the median of (10, 30, 20, 40)
is 30; the median of (10, 10, 10, 20, 30) is 10.
Snuke comes up with the following problem.
You are given a sequence a of length N. For each pair (l, r) (1 \leq l \leq r
\leq N), let m_{l, r} be the median of the contiguous subsequence (a_l, a_{l +
1}, ..., a_r) of a. We will list m_{l, r} for all pairs (l, r) to create a new
sequence m. Find the median of m.
|
[{"input": "3\n 10 30 20", "output": "30\n \n\nThe median of each contiguous subsequence of a is as follows:\n\n * The median of (10) is 10.\n * The median of (30) is 30.\n * The median of (20) is 20.\n * The median of (10, 30) is 30.\n * The median of (30, 20) is 30.\n * The median of (10, 30, 20) is 20.\n\nThus, m = (10, 30, 20, 30, 30, 20) and the median of m is 30.\n\n* * *"}, {"input": "1\n 10", "output": "10\n \n\n* * *"}, {"input": "10\n 5 9 5 9 8 9 3 5 4 3", "output": "8"}]
|
Print the original password.
* * *
|
s944799024
|
Accepted
|
p03760
|
Input is given from Standard Input in the following format:
O
E
|
import queue
o = input()
e = input()
odd = list(o)
even = list(e)
answer = []
o_q = queue.Queue()
e_q = queue.Queue()
for i in range(len(odd)):
o_q.put(odd[i])
for i in range(len(even)):
e_q.put(even[i])
while not o_q.empty():
answer.append(o_q.get())
if e_q.empty():
continue
answer.append(e_q.get())
for i in range(len(answer)):
print(answer[i], end="")
|
Statement
Snuke signed up for a new website which holds programming competitions. He
worried that he might forget his password, and he took notes of it. Since
directly recording his password would cause him trouble if stolen, he took two
notes: one contains the characters at the odd-numbered positions, and the
other contains the characters at the even-numbered positions.
You are given two strings O and E. O contains the characters at the odd-
numbered positions retaining their relative order, and E contains the
characters at the even-numbered positions retaining their relative order.
Restore the original password.
|
[{"input": "xyz\n abc", "output": "xaybzc\n \n\nThe original password is `xaybzc`. Extracting the characters at the odd-\nnumbered positions results in `xyz`, and extracting the characters at the\neven-numbered positions results in `abc`.\n\n* * *"}, {"input": "atcoderbeginnercontest\n atcoderregularcontest", "output": "aattccooddeerrbreeggiunlnaerrccoonntteesstt"}]
|
Print the original password.
* * *
|
s375389596
|
Runtime Error
|
p03760
|
Input is given from Standard Input in the following format:
O
E
|
o = input()
e = input()
x = []
if len(o) = len(e):
for i in range(len(o)):
x.append(o[i]+e[1])
else len(o) != len(e):
for i in range(len(e)):
x.append(o[i]+e[i])
x.append(a[-1])
print(*x,sep="")
|
Statement
Snuke signed up for a new website which holds programming competitions. He
worried that he might forget his password, and he took notes of it. Since
directly recording his password would cause him trouble if stolen, he took two
notes: one contains the characters at the odd-numbered positions, and the
other contains the characters at the even-numbered positions.
You are given two strings O and E. O contains the characters at the odd-
numbered positions retaining their relative order, and E contains the
characters at the even-numbered positions retaining their relative order.
Restore the original password.
|
[{"input": "xyz\n abc", "output": "xaybzc\n \n\nThe original password is `xaybzc`. Extracting the characters at the odd-\nnumbered positions results in `xyz`, and extracting the characters at the\neven-numbered positions results in `abc`.\n\n* * *"}, {"input": "atcoderbeginnercontest\n atcoderregularcontest", "output": "aattccooddeerrbreeggiunlnaerrccoonntteesstt"}]
|
Print the original password.
* * *
|
s734571725
|
Runtime Error
|
p03760
|
Input is given from Standard Input in the following format:
O
E
|
o = input()
e = input()
x = []
if len(o) == len(e):
for i in range(len(o)):
x.append(o[i]+e[1])
else len(o) != len(e):
for i in range(len(e)):
x.append(o[i]+e[i])
x.append(a[-1])
print(*x,sep="")
|
Statement
Snuke signed up for a new website which holds programming competitions. He
worried that he might forget his password, and he took notes of it. Since
directly recording his password would cause him trouble if stolen, he took two
notes: one contains the characters at the odd-numbered positions, and the
other contains the characters at the even-numbered positions.
You are given two strings O and E. O contains the characters at the odd-
numbered positions retaining their relative order, and E contains the
characters at the even-numbered positions retaining their relative order.
Restore the original password.
|
[{"input": "xyz\n abc", "output": "xaybzc\n \n\nThe original password is `xaybzc`. Extracting the characters at the odd-\nnumbered positions results in `xyz`, and extracting the characters at the\neven-numbered positions results in `abc`.\n\n* * *"}, {"input": "atcoderbeginnercontest\n atcoderregularcontest", "output": "aattccooddeerrbreeggiunlnaerrccoonntteesstt"}]
|
Print the original password.
* * *
|
s763016397
|
Runtime Error
|
p03760
|
Input is given from Standard Input in the following format:
O
E
|
o = input()
e = input()
lis = []
for i in range(min(len(o),len(e)):
lis.append(o[i])
lis.append(e[i])
if len(o)>len(e):
lis.append(o[-1])
elif len(o)==len(e):
lis.append(o[-1])
lis.append(e[-1])
print(''.join(lis))
|
Statement
Snuke signed up for a new website which holds programming competitions. He
worried that he might forget his password, and he took notes of it. Since
directly recording his password would cause him trouble if stolen, he took two
notes: one contains the characters at the odd-numbered positions, and the
other contains the characters at the even-numbered positions.
You are given two strings O and E. O contains the characters at the odd-
numbered positions retaining their relative order, and E contains the
characters at the even-numbered positions retaining their relative order.
Restore the original password.
|
[{"input": "xyz\n abc", "output": "xaybzc\n \n\nThe original password is `xaybzc`. Extracting the characters at the odd-\nnumbered positions results in `xyz`, and extracting the characters at the\neven-numbered positions results in `abc`.\n\n* * *"}, {"input": "atcoderbeginnercontest\n atcoderregularcontest", "output": "aattccooddeerrbreeggiunlnaerrccoonntteesstt"}]
|
Print the original password.
* * *
|
s889350516
|
Runtime Error
|
p03760
|
Input is given from Standard Input in the following format:
O
E
|
import sys
def rs():
return sys.stdin.readline().rstrip()
def ri():
return int(rs())
def rs_():
return [_ for _ in rs().split()]
def ri_():
return [int(_) for _ in rs().split()]
import numpy as np
v = np.stack([np.array(list(rs()), dtype=object), np.array(list(rs()), dtype=object)])
v = v.T.flatten()
print("".join(v))
|
Statement
Snuke signed up for a new website which holds programming competitions. He
worried that he might forget his password, and he took notes of it. Since
directly recording his password would cause him trouble if stolen, he took two
notes: one contains the characters at the odd-numbered positions, and the
other contains the characters at the even-numbered positions.
You are given two strings O and E. O contains the characters at the odd-
numbered positions retaining their relative order, and E contains the
characters at the even-numbered positions retaining their relative order.
Restore the original password.
|
[{"input": "xyz\n abc", "output": "xaybzc\n \n\nThe original password is `xaybzc`. Extracting the characters at the odd-\nnumbered positions results in `xyz`, and extracting the characters at the\neven-numbered positions results in `abc`.\n\n* * *"}, {"input": "atcoderbeginnercontest\n atcoderregularcontest", "output": "aattccooddeerrbreeggiunlnaerrccoonntteesstt"}]
|
Print the original password.
* * *
|
s520057436
|
Runtime Error
|
p03760
|
Input is given from Standard Input in the following format:
O
E
|
o = input()
e = input()
n = len(e)
ans = ''
for i in range(n)
ans += o[i]
ans += e[i]
if len(o)%2==1:
ans += o[-1]
print(ans)
|
Statement
Snuke signed up for a new website which holds programming competitions. He
worried that he might forget his password, and he took notes of it. Since
directly recording his password would cause him trouble if stolen, he took two
notes: one contains the characters at the odd-numbered positions, and the
other contains the characters at the even-numbered positions.
You are given two strings O and E. O contains the characters at the odd-
numbered positions retaining their relative order, and E contains the
characters at the even-numbered positions retaining their relative order.
Restore the original password.
|
[{"input": "xyz\n abc", "output": "xaybzc\n \n\nThe original password is `xaybzc`. Extracting the characters at the odd-\nnumbered positions results in `xyz`, and extracting the characters at the\neven-numbered positions results in `abc`.\n\n* * *"}, {"input": "atcoderbeginnercontest\n atcoderregularcontest", "output": "aattccooddeerrbreeggiunlnaerrccoonntteesstt"}]
|
Print the original password.
* * *
|
s660644258
|
Accepted
|
p03760
|
Input is given from Standard Input in the following format:
O
E
|
print("".join(sum(zip(input(), input() + " "), ())))
|
Statement
Snuke signed up for a new website which holds programming competitions. He
worried that he might forget his password, and he took notes of it. Since
directly recording his password would cause him trouble if stolen, he took two
notes: one contains the characters at the odd-numbered positions, and the
other contains the characters at the even-numbered positions.
You are given two strings O and E. O contains the characters at the odd-
numbered positions retaining their relative order, and E contains the
characters at the even-numbered positions retaining their relative order.
Restore the original password.
|
[{"input": "xyz\n abc", "output": "xaybzc\n \n\nThe original password is `xaybzc`. Extracting the characters at the odd-\nnumbered positions results in `xyz`, and extracting the characters at the\neven-numbered positions results in `abc`.\n\n* * *"}, {"input": "atcoderbeginnercontest\n atcoderregularcontest", "output": "aattccooddeerrbreeggiunlnaerrccoonntteesstt"}]
|
Print the original password.
* * *
|
s327714330
|
Accepted
|
p03760
|
Input is given from Standard Input in the following format:
O
E
|
a, b = input(), input() + " "
print(*[i + j for i, j in zip(a, b)], sep="")
|
Statement
Snuke signed up for a new website which holds programming competitions. He
worried that he might forget his password, and he took notes of it. Since
directly recording his password would cause him trouble if stolen, he took two
notes: one contains the characters at the odd-numbered positions, and the
other contains the characters at the even-numbered positions.
You are given two strings O and E. O contains the characters at the odd-
numbered positions retaining their relative order, and E contains the
characters at the even-numbered positions retaining their relative order.
Restore the original password.
|
[{"input": "xyz\n abc", "output": "xaybzc\n \n\nThe original password is `xaybzc`. Extracting the characters at the odd-\nnumbered positions results in `xyz`, and extracting the characters at the\neven-numbered positions results in `abc`.\n\n* * *"}, {"input": "atcoderbeginnercontest\n atcoderregularcontest", "output": "aattccooddeerrbreeggiunlnaerrccoonntteesstt"}]
|
Print the original password.
* * *
|
s993235282
|
Accepted
|
p03760
|
Input is given from Standard Input in the following format:
O
E
|
A = list(input())
B = list(input())
L = ["0"] * (len(A) + len(B))
L[::2] = A
L[1::2] = B
print("".join(L))
|
Statement
Snuke signed up for a new website which holds programming competitions. He
worried that he might forget his password, and he took notes of it. Since
directly recording his password would cause him trouble if stolen, he took two
notes: one contains the characters at the odd-numbered positions, and the
other contains the characters at the even-numbered positions.
You are given two strings O and E. O contains the characters at the odd-
numbered positions retaining their relative order, and E contains the
characters at the even-numbered positions retaining their relative order.
Restore the original password.
|
[{"input": "xyz\n abc", "output": "xaybzc\n \n\nThe original password is `xaybzc`. Extracting the characters at the odd-\nnumbered positions results in `xyz`, and extracting the characters at the\neven-numbered positions results in `abc`.\n\n* * *"}, {"input": "atcoderbeginnercontest\n atcoderregularcontest", "output": "aattccooddeerrbreeggiunlnaerrccoonntteesstt"}]
|
Print the original password.
* * *
|
s327175885
|
Runtime Error
|
p03760
|
Input is given from Standard Input in the following format:
O
E
|
a = list(input())
b = list(input())
for x,y zip(a,b):
print(x+y, end = "")
|
Statement
Snuke signed up for a new website which holds programming competitions. He
worried that he might forget his password, and he took notes of it. Since
directly recording his password would cause him trouble if stolen, he took two
notes: one contains the characters at the odd-numbered positions, and the
other contains the characters at the even-numbered positions.
You are given two strings O and E. O contains the characters at the odd-
numbered positions retaining their relative order, and E contains the
characters at the even-numbered positions retaining their relative order.
Restore the original password.
|
[{"input": "xyz\n abc", "output": "xaybzc\n \n\nThe original password is `xaybzc`. Extracting the characters at the odd-\nnumbered positions results in `xyz`, and extracting the characters at the\neven-numbered positions results in `abc`.\n\n* * *"}, {"input": "atcoderbeginnercontest\n atcoderregularcontest", "output": "aattccooddeerrbreeggiunlnaerrccoonntteesstt"}]
|
Print the original password.
* * *
|
s710015028
|
Runtime Error
|
p03760
|
Input is given from Standard Input in the following format:
O
E
|
a = input()
b = input()
c = len(a)
d = len(b)
x = ""
if c <= d:
for i in range(c):
x = x + c[i]
x = x + d[i]
print(x)
if c > d:
for i in range(d):
x = x + c[i]
x = x + d[i]
x = x + c[len(a) - 1]
print(x)
|
Statement
Snuke signed up for a new website which holds programming competitions. He
worried that he might forget his password, and he took notes of it. Since
directly recording his password would cause him trouble if stolen, he took two
notes: one contains the characters at the odd-numbered positions, and the
other contains the characters at the even-numbered positions.
You are given two strings O and E. O contains the characters at the odd-
numbered positions retaining their relative order, and E contains the
characters at the even-numbered positions retaining their relative order.
Restore the original password.
|
[{"input": "xyz\n abc", "output": "xaybzc\n \n\nThe original password is `xaybzc`. Extracting the characters at the odd-\nnumbered positions results in `xyz`, and extracting the characters at the\neven-numbered positions results in `abc`.\n\n* * *"}, {"input": "atcoderbeginnercontest\n atcoderregularcontest", "output": "aattccooddeerrbreeggiunlnaerrccoonntteesstt"}]
|
Print the original password.
* * *
|
s542903231
|
Runtime Error
|
p03760
|
Input is given from Standard Input in the following format:
O
E
|
from collections import deque
O=input()
E=input()
o=deque(O)
e=deque(E)
s=''
While True:
if not e a and not o:
break
elif o:
s+=o.pop()
elif e:
s+=e.pop()
print(s)
|
Statement
Snuke signed up for a new website which holds programming competitions. He
worried that he might forget his password, and he took notes of it. Since
directly recording his password would cause him trouble if stolen, he took two
notes: one contains the characters at the odd-numbered positions, and the
other contains the characters at the even-numbered positions.
You are given two strings O and E. O contains the characters at the odd-
numbered positions retaining their relative order, and E contains the
characters at the even-numbered positions retaining their relative order.
Restore the original password.
|
[{"input": "xyz\n abc", "output": "xaybzc\n \n\nThe original password is `xaybzc`. Extracting the characters at the odd-\nnumbered positions results in `xyz`, and extracting the characters at the\neven-numbered positions results in `abc`.\n\n* * *"}, {"input": "atcoderbeginnercontest\n atcoderregularcontest", "output": "aattccooddeerrbreeggiunlnaerrccoonntteesstt"}]
|
Print the original password.
* * *
|
s848562855
|
Runtime Error
|
p03760
|
Input is given from Standard Input in the following format:
O
E
|
from collections import deque
O=input()
E=input()
o=deque(O)
e=deque(E)
s=''
While True:
if not e a and not o:
break
elif o:
s+=o.pop()
elif e:
s+=e.pop()
|
Statement
Snuke signed up for a new website which holds programming competitions. He
worried that he might forget his password, and he took notes of it. Since
directly recording his password would cause him trouble if stolen, he took two
notes: one contains the characters at the odd-numbered positions, and the
other contains the characters at the even-numbered positions.
You are given two strings O and E. O contains the characters at the odd-
numbered positions retaining their relative order, and E contains the
characters at the even-numbered positions retaining their relative order.
Restore the original password.
|
[{"input": "xyz\n abc", "output": "xaybzc\n \n\nThe original password is `xaybzc`. Extracting the characters at the odd-\nnumbered positions results in `xyz`, and extracting the characters at the\neven-numbered positions results in `abc`.\n\n* * *"}, {"input": "atcoderbeginnercontest\n atcoderregularcontest", "output": "aattccooddeerrbreeggiunlnaerrccoonntteesstt"}]
|
Print the original password.
* * *
|
s674310645
|
Wrong Answer
|
p03760
|
Input is given from Standard Input in the following format:
O
E
|
print("".join(sum(map(list, zip(input(), input())), [])))
|
Statement
Snuke signed up for a new website which holds programming competitions. He
worried that he might forget his password, and he took notes of it. Since
directly recording his password would cause him trouble if stolen, he took two
notes: one contains the characters at the odd-numbered positions, and the
other contains the characters at the even-numbered positions.
You are given two strings O and E. O contains the characters at the odd-
numbered positions retaining their relative order, and E contains the
characters at the even-numbered positions retaining their relative order.
Restore the original password.
|
[{"input": "xyz\n abc", "output": "xaybzc\n \n\nThe original password is `xaybzc`. Extracting the characters at the odd-\nnumbered positions results in `xyz`, and extracting the characters at the\neven-numbered positions results in `abc`.\n\n* * *"}, {"input": "atcoderbeginnercontest\n atcoderregularcontest", "output": "aattccooddeerrbreeggiunlnaerrccoonntteesstt"}]
|
Print the original password.
* * *
|
s273922864
|
Runtime Error
|
p03760
|
Input is given from Standard Input in the following format:
O
E
|
o = list(input())
e = list(input())
e_ni = e.append('a')
l = []
if len(o) == len(e):
for i in range (len(o)):
a = o[i]
b = e[i]
l.append(a)
l.append(b)
else:
for i in range (len(o)):
a = o[i]
b = e[i]
l.append(a)
l.append(b)
del l[-1]
s = ''.join(l)
print(s)
|
Statement
Snuke signed up for a new website which holds programming competitions. He
worried that he might forget his password, and he took notes of it. Since
directly recording his password would cause him trouble if stolen, he took two
notes: one contains the characters at the odd-numbered positions, and the
other contains the characters at the even-numbered positions.
You are given two strings O and E. O contains the characters at the odd-
numbered positions retaining their relative order, and E contains the
characters at the even-numbered positions retaining their relative order.
Restore the original password.
|
[{"input": "xyz\n abc", "output": "xaybzc\n \n\nThe original password is `xaybzc`. Extracting the characters at the odd-\nnumbered positions results in `xyz`, and extracting the characters at the\neven-numbered positions results in `abc`.\n\n* * *"}, {"input": "atcoderbeginnercontest\n atcoderregularcontest", "output": "aattccooddeerrbreeggiunlnaerrccoonntteesstt"}]
|
Print the original password.
* * *
|
s083271037
|
Runtime Error
|
p03760
|
Input is given from Standard Input in the following format:
O
E
|
O=[]
E=[]
P=[]
Olength=int(input("Enter the length of odd Characters")
for i in range (o,Olength):
x=input("ENTER cHARACTERS")
O.append(x)
Elength=int(input("Enter the length of even Characters")
for i in range (o,Elength):
x=input("ENTER cHARACTERS")
E.append(x)
for i in range (o,Olength):
P.append(O[i])
P.append(E[i])
for i in range (o, P.length):
print(P[i])
|
Statement
Snuke signed up for a new website which holds programming competitions. He
worried that he might forget his password, and he took notes of it. Since
directly recording his password would cause him trouble if stolen, he took two
notes: one contains the characters at the odd-numbered positions, and the
other contains the characters at the even-numbered positions.
You are given two strings O and E. O contains the characters at the odd-
numbered positions retaining their relative order, and E contains the
characters at the even-numbered positions retaining their relative order.
Restore the original password.
|
[{"input": "xyz\n abc", "output": "xaybzc\n \n\nThe original password is `xaybzc`. Extracting the characters at the odd-\nnumbered positions results in `xyz`, and extracting the characters at the\neven-numbered positions results in `abc`.\n\n* * *"}, {"input": "atcoderbeginnercontest\n atcoderregularcontest", "output": "aattccooddeerrbreeggiunlnaerrccoonntteesstt"}]
|
Print the original password.
* * *
|
s341768029
|
Accepted
|
p03760
|
Input is given from Standard Input in the following format:
O
E
|
print(*(x + y for x, y in zip(input(), input() + " ")), sep="")
|
Statement
Snuke signed up for a new website which holds programming competitions. He
worried that he might forget his password, and he took notes of it. Since
directly recording his password would cause him trouble if stolen, he took two
notes: one contains the characters at the odd-numbered positions, and the
other contains the characters at the even-numbered positions.
You are given two strings O and E. O contains the characters at the odd-
numbered positions retaining their relative order, and E contains the
characters at the even-numbered positions retaining their relative order.
Restore the original password.
|
[{"input": "xyz\n abc", "output": "xaybzc\n \n\nThe original password is `xaybzc`. Extracting the characters at the odd-\nnumbered positions results in `xyz`, and extracting the characters at the\neven-numbered positions results in `abc`.\n\n* * *"}, {"input": "atcoderbeginnercontest\n atcoderregularcontest", "output": "aattccooddeerrbreeggiunlnaerrccoonntteesstt"}]
|
Print the original password.
* * *
|
s869837107
|
Accepted
|
p03760
|
Input is given from Standard Input in the following format:
O
E
|
s = [input() for _ in range(2)]
print("".join(s[i % 2][i // 2] for i in range(len(s[0]) + len(s[1]))))
|
Statement
Snuke signed up for a new website which holds programming competitions. He
worried that he might forget his password, and he took notes of it. Since
directly recording his password would cause him trouble if stolen, he took two
notes: one contains the characters at the odd-numbered positions, and the
other contains the characters at the even-numbered positions.
You are given two strings O and E. O contains the characters at the odd-
numbered positions retaining their relative order, and E contains the
characters at the even-numbered positions retaining their relative order.
Restore the original password.
|
[{"input": "xyz\n abc", "output": "xaybzc\n \n\nThe original password is `xaybzc`. Extracting the characters at the odd-\nnumbered positions results in `xyz`, and extracting the characters at the\neven-numbered positions results in `abc`.\n\n* * *"}, {"input": "atcoderbeginnercontest\n atcoderregularcontest", "output": "aattccooddeerrbreeggiunlnaerrccoonntteesstt"}]
|
Print the original password.
* * *
|
s417314634
|
Accepted
|
p03760
|
Input is given from Standard Input in the following format:
O
E
|
o, e = input(), input() + " "
print("".join(map("".join, zip(o, e))))
|
Statement
Snuke signed up for a new website which holds programming competitions. He
worried that he might forget his password, and he took notes of it. Since
directly recording his password would cause him trouble if stolen, he took two
notes: one contains the characters at the odd-numbered positions, and the
other contains the characters at the even-numbered positions.
You are given two strings O and E. O contains the characters at the odd-
numbered positions retaining their relative order, and E contains the
characters at the even-numbered positions retaining their relative order.
Restore the original password.
|
[{"input": "xyz\n abc", "output": "xaybzc\n \n\nThe original password is `xaybzc`. Extracting the characters at the odd-\nnumbered positions results in `xyz`, and extracting the characters at the\neven-numbered positions results in `abc`.\n\n* * *"}, {"input": "atcoderbeginnercontest\n atcoderregularcontest", "output": "aattccooddeerrbreeggiunlnaerrccoonntteesstt"}]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.