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 earliest possible time for the last dish to be delivered, as an
integer.
* * * | s624979505 | Accepted | p03076 | Input is given from Standard Input in the following format:
A
B
C
D
E | ts = []
for _ in range(5):
ts.append(int(input()))
min_r_t = 12
min_r_t_index = -1
for i, t in enumerate(ts):
r_t = t % 10
if r_t == 0:
continue
if r_t < min_r_t:
min_r_t_index = i
min_r_t = r_t
sum_t = 0
for i, t in enumerate(ts):
if t % 10 == 0:
sum_t += t
elif i == min_r_t_index:
sum_t += t
else:
sum_t += ((t // 10) + 1) * 10
print(sum_t)
| Statement
The restaurant AtCoder serves the following five dishes:
* ABC Don (rice bowl): takes A minutes to serve.
* ARC Curry: takes B minutes to serve.
* AGC Pasta: takes C minutes to serve.
* APC Ramen: takes D minutes to serve.
* ATC Hanbagu (hamburger patty): takes E minutes to serve.
Here, the time to serve a dish is the time between when an order is placed and
when the dish is delivered.
This restaurant has the following rules on orders:
* An order can only be placed at a time that is a multiple of 10 (time 0, 10, 20, ...).
* Only one dish can be ordered at a time.
* No new order can be placed when an order is already placed and the dish is still not delivered, but a new order can be placed at the exact time when the dish is delivered.
E869120 arrives at this restaurant at time 0. He will order all five dishes.
Find the earliest possible time for the last dish to be delivered.
Here, he can order the dishes in any order he likes, and he can place an order
already at time 0. | [{"input": "29\n 20\n 7\n 35\n 120", "output": "215\n \n\nIf we decide to order the dishes in the order ABC Don, ARC Curry, AGC Pasta,\nATC Hanbagu, APC Ramen, the earliest possible time for each order is as\nfollows:\n\n * Order ABC Don at time 0, which will be delivered at time 29.\n * Order ARC Curry at time 30, which will be delivered at time 50.\n * Order AGC Pasta at time 50, which will be delivered at time 57.\n * Order ATC Hanbagu at time 60, which will be delivered at time 180.\n * Order APC Ramen at time 180, which will be delivered at time 215.\n\nThere is no way to order the dishes in which the last dish will be delivered\nearlier than this.\n\n* * *"}, {"input": "101\n 86\n 119\n 108\n 57", "output": "481\n \n\nIf we decide to order the dishes in the order AGC Pasta, ARC Curry, ATC\nHanbagu, APC Ramen, ABC Don, the earliest possible time for each order is as\nfollows:\n\n * Order AGC Pasta at time 0, which will be delivered at time 119.\n * Order ARC Curry at time 120, which will be delivered at time 206.\n * Order ATC Hanbagu at time 210, which will be delivered at time 267.\n * Order APC Ramen at time 270, which will be delivered at time 378.\n * Order ABC Don at time 380, which will be delivered at time 481.\n\nThere is no way to order the dishes in which the last dish will be delivered\nearlier than this.\n\n* * *"}, {"input": "123\n 123\n 123\n 123\n 123", "output": "643\n \n\nThis is the largest valid case."}] |
As shown in the following sample output, print the adjacent-matrix
representation of $G$. Put a single space character between $a_{ij}$. | s255401776 | Accepted | p02237 | In the first line, an integer $n$ is given. In the next $n$ lines, an
adjacency list $Adj[u]$ for vertex $u$ are given in the following format:
$u$ $k$ $v_1$ $v_2$ ... $v_k$
$u$ is vertex ID and $k$ denotes its degree. $v_i$ are IDs of vertices
adjacent to $u$. | # your code goes here
# graph
# ????????????????¨?????????¨
n = int(input())
L = []
for i in range(n):
L.append([])
for j in range(n):
L[i].append("0")
# rint(L)
for i in range(n):
v = [int(i) for i in input().split()]
# print(v)
for j in range(2, 2 + v[1]):
L[v[0] - 1][v[j] - 1] = "1" # ??????????????????1????????????i???i-1
# print(L)
# L[v[j]-1][v[0]-1]="1"
for i in range(n):
print(" ".join(L[i]))
| Graph
There are two standard ways to represent a graph $G = (V, E)$, where $V$ is a
set of vertices and $E$ is a set of edges; Adjacency list representation and
Adjacency matrix representation.
An adjacency-list representation consists of an array $Adj[|V|]$ of $|V|$
lists, one for each vertex in $V$. For each $u \in V$, the adjacency list
$Adj[u]$ contains all vertices $v$ such that there is an edge $(u, v) \in E$.
That is, $Adj[u]$ consists of all vertices adjacent to $u$ in $G$.
An adjacency-matrix representation consists of $|V| \times |V|$ matrix $A =
a_{ij}$ such that $a_{ij} = 1$ if $(i, j) \in E$, $a_{ij} = 0$ otherwise.
Write a program which reads a directed graph $G$ represented by the adjacency
list, and prints its adjacency-matrix representation. $G$ consists of $n\;
(=|V|)$ vertices identified by their IDs $1, 2,.., n$ respectively. | [{"input": "1 2 2 4\n 2 1 4\n 3 0\n 4 1 3", "output": "1 0 1\n 0 0 0 1\n 0 0 0 0\n 0 0 1 0"}] |
As shown in the following sample output, print the adjacent-matrix
representation of $G$. Put a single space character between $a_{ij}$. | s975217761 | Wrong Answer | p02237 | In the first line, an integer $n$ is given. In the next $n$ lines, an
adjacency list $Adj[u]$ for vertex $u$ are given in the following format:
$u$ $k$ $v_1$ $v_2$ ... $v_k$
$u$ is vertex ID and $k$ denotes its degree. $v_i$ are IDs of vertices
adjacent to $u$. | if __name__ == "__main__":
N = int(input())
matrix = [[0] * N for _ in range(N)]
for i in matrix:
node_info = [int(i) for i in input().split()]
node_i = node_info[0] - 1
if not node_info[1] == 0:
for i in node_info[2:]:
matrix[node_i][i - 1] = 1
[print(line) for line in matrix]
| Graph
There are two standard ways to represent a graph $G = (V, E)$, where $V$ is a
set of vertices and $E$ is a set of edges; Adjacency list representation and
Adjacency matrix representation.
An adjacency-list representation consists of an array $Adj[|V|]$ of $|V|$
lists, one for each vertex in $V$. For each $u \in V$, the adjacency list
$Adj[u]$ contains all vertices $v$ such that there is an edge $(u, v) \in E$.
That is, $Adj[u]$ consists of all vertices adjacent to $u$ in $G$.
An adjacency-matrix representation consists of $|V| \times |V|$ matrix $A =
a_{ij}$ such that $a_{ij} = 1$ if $(i, j) \in E$, $a_{ij} = 0$ otherwise.
Write a program which reads a directed graph $G$ represented by the adjacency
list, and prints its adjacency-matrix representation. $G$ consists of $n\;
(=|V|)$ vertices identified by their IDs $1, 2,.., n$ respectively. | [{"input": "1 2 2 4\n 2 1 4\n 3 0\n 4 1 3", "output": "1 0 1\n 0 0 0 1\n 0 0 0 0\n 0 0 1 0"}] |
As shown in the following sample output, print the adjacent-matrix
representation of $G$. Put a single space character between $a_{ij}$. | s292641339 | Accepted | p02237 | In the first line, an integer $n$ is given. In the next $n$ lines, an
adjacency list $Adj[u]$ for vertex $u$ are given in the following format:
$u$ $k$ $v_1$ $v_2$ ... $v_k$
$u$ is vertex ID and $k$ denotes its degree. $v_i$ are IDs of vertices
adjacent to $u$. | n = int(input())
for _ in [0] * n:
a = [0] * n
for i in list(map(int, input().split()))[2:]:
a[i - 1] = 1
print(*a)
| Graph
There are two standard ways to represent a graph $G = (V, E)$, where $V$ is a
set of vertices and $E$ is a set of edges; Adjacency list representation and
Adjacency matrix representation.
An adjacency-list representation consists of an array $Adj[|V|]$ of $|V|$
lists, one for each vertex in $V$. For each $u \in V$, the adjacency list
$Adj[u]$ contains all vertices $v$ such that there is an edge $(u, v) \in E$.
That is, $Adj[u]$ consists of all vertices adjacent to $u$ in $G$.
An adjacency-matrix representation consists of $|V| \times |V|$ matrix $A =
a_{ij}$ such that $a_{ij} = 1$ if $(i, j) \in E$, $a_{ij} = 0$ otherwise.
Write a program which reads a directed graph $G$ represented by the adjacency
list, and prints its adjacency-matrix representation. $G$ consists of $n\;
(=|V|)$ vertices identified by their IDs $1, 2,.., n$ respectively. | [{"input": "1 2 2 4\n 2 1 4\n 3 0\n 4 1 3", "output": "1 0 1\n 0 0 0 1\n 0 0 0 0\n 0 0 1 0"}] |
As shown in the following sample output, print the adjacent-matrix
representation of $G$. Put a single space character between $a_{ij}$. | s790980247 | Accepted | p02237 | In the first line, an integer $n$ is given. In the next $n$ lines, an
adjacency list $Adj[u]$ for vertex $u$ are given in the following format:
$u$ $k$ $v_1$ $v_2$ ... $v_k$
$u$ is vertex ID and $k$ denotes its degree. $v_i$ are IDs of vertices
adjacent to $u$. | num = int(input())
L = [[0 for x in range(num)] for y in range(num)]
for _ in range(num):
c, k, *v = [int(x) - 1 for x in input().split()]
for i in v:
L[c][i] = 1
for i in range(num):
print(*L[i])
| Graph
There are two standard ways to represent a graph $G = (V, E)$, where $V$ is a
set of vertices and $E$ is a set of edges; Adjacency list representation and
Adjacency matrix representation.
An adjacency-list representation consists of an array $Adj[|V|]$ of $|V|$
lists, one for each vertex in $V$. For each $u \in V$, the adjacency list
$Adj[u]$ contains all vertices $v$ such that there is an edge $(u, v) \in E$.
That is, $Adj[u]$ consists of all vertices adjacent to $u$ in $G$.
An adjacency-matrix representation consists of $|V| \times |V|$ matrix $A =
a_{ij}$ such that $a_{ij} = 1$ if $(i, j) \in E$, $a_{ij} = 0$ otherwise.
Write a program which reads a directed graph $G$ represented by the adjacency
list, and prints its adjacency-matrix representation. $G$ consists of $n\;
(=|V|)$ vertices identified by their IDs $1, 2,.., n$ respectively. | [{"input": "1 2 2 4\n 2 1 4\n 3 0\n 4 1 3", "output": "1 0 1\n 0 0 0 1\n 0 0 0 0\n 0 0 1 0"}] |
As shown in the following sample output, print the adjacent-matrix
representation of $G$. Put a single space character between $a_{ij}$. | s551329687 | Accepted | p02237 | In the first line, an integer $n$ is given. In the next $n$ lines, an
adjacency list $Adj[u]$ for vertex $u$ are given in the following format:
$u$ $k$ $v_1$ $v_2$ ... $v_k$
$u$ is vertex ID and $k$ denotes its degree. $v_i$ are IDs of vertices
adjacent to $u$. | n = int(input())
rlist = [[]]
alist = [[]]
for i in range(n):
alist.append(input().split())
rlist.append([0] * n)
alist.pop(0)
rlist.pop(0)
for i in range(n):
for j in range(2, len(alist[i])):
rlist[i][int(alist[i][j]) - 1] = 1
print(*rlist[i])
| Graph
There are two standard ways to represent a graph $G = (V, E)$, where $V$ is a
set of vertices and $E$ is a set of edges; Adjacency list representation and
Adjacency matrix representation.
An adjacency-list representation consists of an array $Adj[|V|]$ of $|V|$
lists, one for each vertex in $V$. For each $u \in V$, the adjacency list
$Adj[u]$ contains all vertices $v$ such that there is an edge $(u, v) \in E$.
That is, $Adj[u]$ consists of all vertices adjacent to $u$ in $G$.
An adjacency-matrix representation consists of $|V| \times |V|$ matrix $A =
a_{ij}$ such that $a_{ij} = 1$ if $(i, j) \in E$, $a_{ij} = 0$ otherwise.
Write a program which reads a directed graph $G$ represented by the adjacency
list, and prints its adjacency-matrix representation. $G$ consists of $n\;
(=|V|)$ vertices identified by their IDs $1, 2,.., n$ respectively. | [{"input": "1 2 2 4\n 2 1 4\n 3 0\n 4 1 3", "output": "1 0 1\n 0 0 0 1\n 0 0 0 0\n 0 0 1 0"}] |
As shown in the following sample output, print the adjacent-matrix
representation of $G$. Put a single space character between $a_{ij}$. | s625018753 | Accepted | p02237 | In the first line, an integer $n$ is given. In the next $n$ lines, an
adjacency list $Adj[u]$ for vertex $u$ are given in the following format:
$u$ $k$ $v_1$ $v_2$ ... $v_k$
$u$ is vertex ID and $k$ denotes its degree. $v_i$ are IDs of vertices
adjacent to $u$. | n = int(input())
L = [[] for _ in range(n)]
for i in range(n):
L[i] = [i for i in map(int, input().split())]
L[i].remove(L[i][0])
if L[i] != []:
L[i].remove(L[i][0])
for i in range(n):
adjacent = [0 for _ in range(n)]
for el in L[i]:
adjacent[el - 1] = 1
print(" ".join(map(str, adjacent)))
| Graph
There are two standard ways to represent a graph $G = (V, E)$, where $V$ is a
set of vertices and $E$ is a set of edges; Adjacency list representation and
Adjacency matrix representation.
An adjacency-list representation consists of an array $Adj[|V|]$ of $|V|$
lists, one for each vertex in $V$. For each $u \in V$, the adjacency list
$Adj[u]$ contains all vertices $v$ such that there is an edge $(u, v) \in E$.
That is, $Adj[u]$ consists of all vertices adjacent to $u$ in $G$.
An adjacency-matrix representation consists of $|V| \times |V|$ matrix $A =
a_{ij}$ such that $a_{ij} = 1$ if $(i, j) \in E$, $a_{ij} = 0$ otherwise.
Write a program which reads a directed graph $G$ represented by the adjacency
list, and prints its adjacency-matrix representation. $G$ consists of $n\;
(=|V|)$ vertices identified by their IDs $1, 2,.., n$ respectively. | [{"input": "1 2 2 4\n 2 1 4\n 3 0\n 4 1 3", "output": "1 0 1\n 0 0 0 1\n 0 0 0 0\n 0 0 1 0"}] |
As shown in the following sample output, print the adjacent-matrix
representation of $G$. Put a single space character between $a_{ij}$. | s725240178 | Accepted | p02237 | In the first line, an integer $n$ is given. In the next $n$ lines, an
adjacency list $Adj[u]$ for vertex $u$ are given in the following format:
$u$ $k$ $v_1$ $v_2$ ... $v_k$
$u$ is vertex ID and $k$ denotes its degree. $v_i$ are IDs of vertices
adjacent to $u$. | n = int(input())
for i in range(n):
(
u,
k,
*v,
) = map(int, input().split())
r = []
for j in range(1, n + 1):
r.append(str(1 if j in v else 0))
print(" ".join(r))
| Graph
There are two standard ways to represent a graph $G = (V, E)$, where $V$ is a
set of vertices and $E$ is a set of edges; Adjacency list representation and
Adjacency matrix representation.
An adjacency-list representation consists of an array $Adj[|V|]$ of $|V|$
lists, one for each vertex in $V$. For each $u \in V$, the adjacency list
$Adj[u]$ contains all vertices $v$ such that there is an edge $(u, v) \in E$.
That is, $Adj[u]$ consists of all vertices adjacent to $u$ in $G$.
An adjacency-matrix representation consists of $|V| \times |V|$ matrix $A =
a_{ij}$ such that $a_{ij} = 1$ if $(i, j) \in E$, $a_{ij} = 0$ otherwise.
Write a program which reads a directed graph $G$ represented by the adjacency
list, and prints its adjacency-matrix representation. $G$ consists of $n\;
(=|V|)$ vertices identified by their IDs $1, 2,.., n$ respectively. | [{"input": "1 2 2 4\n 2 1 4\n 3 0\n 4 1 3", "output": "1 0 1\n 0 0 0 1\n 0 0 0 0\n 0 0 1 0"}] |
As shown in the following sample output, print the adjacent-matrix
representation of $G$. Put a single space character between $a_{ij}$. | s327717324 | Accepted | p02237 | In the first line, an integer $n$ is given. In the next $n$ lines, an
adjacency list $Adj[u]$ for vertex $u$ are given in the following format:
$u$ $k$ $v_1$ $v_2$ ... $v_k$
$u$ is vertex ID and $k$ denotes its degree. $v_i$ are IDs of vertices
adjacent to $u$. | N = int(input())
for _ in [0] * N:
r = [0] * N
for i in input().split()[2:]:
r[int(i) - 1] = 1
print(*r)
| Graph
There are two standard ways to represent a graph $G = (V, E)$, where $V$ is a
set of vertices and $E$ is a set of edges; Adjacency list representation and
Adjacency matrix representation.
An adjacency-list representation consists of an array $Adj[|V|]$ of $|V|$
lists, one for each vertex in $V$. For each $u \in V$, the adjacency list
$Adj[u]$ contains all vertices $v$ such that there is an edge $(u, v) \in E$.
That is, $Adj[u]$ consists of all vertices adjacent to $u$ in $G$.
An adjacency-matrix representation consists of $|V| \times |V|$ matrix $A =
a_{ij}$ such that $a_{ij} = 1$ if $(i, j) \in E$, $a_{ij} = 0$ otherwise.
Write a program which reads a directed graph $G$ represented by the adjacency
list, and prints its adjacency-matrix representation. $G$ consists of $n\;
(=|V|)$ vertices identified by their IDs $1, 2,.., n$ respectively. | [{"input": "1 2 2 4\n 2 1 4\n 3 0\n 4 1 3", "output": "1 0 1\n 0 0 0 1\n 0 0 0 0\n 0 0 1 0"}] |
As shown in the following sample output, print the adjacent-matrix
representation of $G$. Put a single space character between $a_{ij}$. | s376027062 | Runtime Error | p02237 | In the first line, an integer $n$ is given. In the next $n$ lines, an
adjacency list $Adj[u]$ for vertex $u$ are given in the following format:
$u$ $k$ $v_1$ $v_2$ ... $v_k$
$u$ is vertex ID and $k$ denotes its degree. $v_i$ are IDs of vertices
adjacent to $u$. | v_num = int(input())
adjacent = [[0 for n in range(v_num)] for m in range(v_num)]
for _ in range(v_num):
inp = (int(n) for n in input().split(" "))
for i in inp[2:]:
adjacent[inp[0] - 1][i - 1] = 1
for i in range(v_num):
print(*adjacent[i])
| Graph
There are two standard ways to represent a graph $G = (V, E)$, where $V$ is a
set of vertices and $E$ is a set of edges; Adjacency list representation and
Adjacency matrix representation.
An adjacency-list representation consists of an array $Adj[|V|]$ of $|V|$
lists, one for each vertex in $V$. For each $u \in V$, the adjacency list
$Adj[u]$ contains all vertices $v$ such that there is an edge $(u, v) \in E$.
That is, $Adj[u]$ consists of all vertices adjacent to $u$ in $G$.
An adjacency-matrix representation consists of $|V| \times |V|$ matrix $A =
a_{ij}$ such that $a_{ij} = 1$ if $(i, j) \in E$, $a_{ij} = 0$ otherwise.
Write a program which reads a directed graph $G$ represented by the adjacency
list, and prints its adjacency-matrix representation. $G$ consists of $n\;
(=|V|)$ vertices identified by their IDs $1, 2,.., n$ respectively. | [{"input": "1 2 2 4\n 2 1 4\n 3 0\n 4 1 3", "output": "1 0 1\n 0 0 0 1\n 0 0 0 0\n 0 0 1 0"}] |
As shown in the following sample output, print the adjacent-matrix
representation of $G$. Put a single space character between $a_{ij}$. | s394078428 | Accepted | p02237 | In the first line, an integer $n$ is given. In the next $n$ lines, an
adjacency list $Adj[u]$ for vertex $u$ are given in the following format:
$u$ $k$ $v_1$ $v_2$ ... $v_k$
$u$ is vertex ID and $k$ denotes its degree. $v_i$ are IDs of vertices
adjacent to $u$. | from sys import stdin
from collections import deque
def print_2d_array(A):
for i in range(1, len(A)):
print(*A[i][1:], sep=" ")
def read_and_print_graph(n):
A = [[0] * (n + 1) for _ in range(n + 1)]
for _ in range(n):
line = deque(stdin.readline().strip().split())
i = line.popleft()
line.popleft()
for k in line:
A[int(i)][int(k)] = 1
print_2d_array(A)
n = int(input())
read_and_print_graph(n)
| Graph
There are two standard ways to represent a graph $G = (V, E)$, where $V$ is a
set of vertices and $E$ is a set of edges; Adjacency list representation and
Adjacency matrix representation.
An adjacency-list representation consists of an array $Adj[|V|]$ of $|V|$
lists, one for each vertex in $V$. For each $u \in V$, the adjacency list
$Adj[u]$ contains all vertices $v$ such that there is an edge $(u, v) \in E$.
That is, $Adj[u]$ consists of all vertices adjacent to $u$ in $G$.
An adjacency-matrix representation consists of $|V| \times |V|$ matrix $A =
a_{ij}$ such that $a_{ij} = 1$ if $(i, j) \in E$, $a_{ij} = 0$ otherwise.
Write a program which reads a directed graph $G$ represented by the adjacency
list, and prints its adjacency-matrix representation. $G$ consists of $n\;
(=|V|)$ vertices identified by their IDs $1, 2,.., n$ respectively. | [{"input": "1 2 2 4\n 2 1 4\n 3 0\n 4 1 3", "output": "1 0 1\n 0 0 0 1\n 0 0 0 0\n 0 0 1 0"}] |
Print the maximum possible final value of x in a sequence of operations such
that S equals T in the end.
* * * | s709113314 | Wrong Answer | p02667 | Input is given from Standard Input in the following format:
T | s = input()
def get(s):
n = len(s)
ans = 0
a = 0
for i in range(0, n, 2):
if s[i] == "1":
a += 1
b = 0
c = 0
no = n
for i in reversed(range(n)):
if s[i] == "1":
if i % 2 == 0:
a -= 1
b += 1
else:
c += 1
else:
no -= 1
ans += b + a
b, c = c, b
for i in range(no + 1):
ans += (i + 1) // 2
return ans
ans = 0
if "0" in s:
i = s.index("0")
t = s[:i] + s[i + 1 :]
for i in range(0, len(s), 2):
if s[i] == "1":
ans += 1
ans += get(t)
ans = max(ans, get(s))
print(ans)
| Statement
Takahashi has an empty string S and a variable x whose initial value is 0.
Also, we have a string T consisting of `0` and `1`.
Now, Takahashi will do the operation with the following two steps |T| times.
* Insert a `0` or a `1` at any position of S of his choice.
* Then, increment x by the sum of the digits in the odd positions (first, third, fifth, ...) of S. For example, if S is `01101`, the digits in the odd positions are `0`, `1`, `1` from left to right, so x is incremented by 2.
Print the maximum possible final value of x in a sequence of operations such
that S equals T in the end. | [{"input": "1101", "output": "5\n \n\nBelow is one sequence of operations that maximizes the final value of x to 5.\n\n * Insert a `1` at the beginning of S. S becomes `1`, and x is incremented by 1.\n * Insert a `0` to the immediate right of the first character of S. S becomes `10`, and x is incremented by 1.\n * Insert a `1` to the immediate right of the second character of S. S becomes `101`, and x is incremented by 2.\n * Insert a `1` at the beginning of S. S becomes `1101`, and x is incremented by 1.\n\n* * *"}, {"input": "0111101101", "output": "26"}] |
Print the maximum possible final value of x in a sequence of operations such
that S equals T in the end.
* * * | s887832345 | Wrong Answer | p02667 | Input is given from Standard Input in the following format:
T | a = input()
b = len(a)
a = list(a)
c = b
k = 1
while k < b + 1:
if k % 2 == 1:
a[k - 1] = int(a[k - 1])
c = a[k - 1] + c
k = k + 1
print(c)
| Statement
Takahashi has an empty string S and a variable x whose initial value is 0.
Also, we have a string T consisting of `0` and `1`.
Now, Takahashi will do the operation with the following two steps |T| times.
* Insert a `0` or a `1` at any position of S of his choice.
* Then, increment x by the sum of the digits in the odd positions (first, third, fifth, ...) of S. For example, if S is `01101`, the digits in the odd positions are `0`, `1`, `1` from left to right, so x is incremented by 2.
Print the maximum possible final value of x in a sequence of operations such
that S equals T in the end. | [{"input": "1101", "output": "5\n \n\nBelow is one sequence of operations that maximizes the final value of x to 5.\n\n * Insert a `1` at the beginning of S. S becomes `1`, and x is incremented by 1.\n * Insert a `0` to the immediate right of the first character of S. S becomes `10`, and x is incremented by 1.\n * Insert a `1` to the immediate right of the second character of S. S becomes `101`, and x is incremented by 2.\n * Insert a `1` at the beginning of S. S becomes `1101`, and x is incremented by 1.\n\n* * *"}, {"input": "0111101101", "output": "26"}] |
Print the maximum possible final value of x in a sequence of operations such
that S equals T in the end.
* * * | s382661183 | Wrong Answer | p02667 | Input is given from Standard Input in the following format:
T | import re
t = input()
x = 0
s = ""
k = len(t)
k0 = len(t.replace("0", ""))
iti = [m.start() for m in re.finditer("0", t)]
# print(iti)
GU = 0
KI = 0
for i in iti:
if (i + 1) % 2 == 0:
GU += 1
else:
KI += 1
anst = 0
# print(KI)
if k0 % 2 == 1:
anst = (k0 + 1) * (1 + k0) / 4
# print(anst)
anst = anst + (k0 + 1) / 2 * GU + (((k0 + 1) / 2) - 1) * KI
# print(anst)
else:
anst = k0 / 2 + k0 * k0 / 4
anst = anst + ((k0 / 2) + 0) * GU + (k0 / 2) * KI
print(int(anst))
| Statement
Takahashi has an empty string S and a variable x whose initial value is 0.
Also, we have a string T consisting of `0` and `1`.
Now, Takahashi will do the operation with the following two steps |T| times.
* Insert a `0` or a `1` at any position of S of his choice.
* Then, increment x by the sum of the digits in the odd positions (first, third, fifth, ...) of S. For example, if S is `01101`, the digits in the odd positions are `0`, `1`, `1` from left to right, so x is incremented by 2.
Print the maximum possible final value of x in a sequence of operations such
that S equals T in the end. | [{"input": "1101", "output": "5\n \n\nBelow is one sequence of operations that maximizes the final value of x to 5.\n\n * Insert a `1` at the beginning of S. S becomes `1`, and x is incremented by 1.\n * Insert a `0` to the immediate right of the first character of S. S becomes `10`, and x is incremented by 1.\n * Insert a `1` to the immediate right of the second character of S. S becomes `101`, and x is incremented by 2.\n * Insert a `1` at the beginning of S. S becomes `1101`, and x is incremented by 1.\n\n* * *"}, {"input": "0111101101", "output": "26"}] |
Print the maximum possible final value of x in a sequence of operations such
that S equals T in the end.
* * * | s595752995 | Wrong Answer | p02667 | Input is given from Standard Input in the following format:
T | t = input()
num = 0
for i in range(len(t)):
num += t[1::2].count("1")
t = t[:-1]
num1 = 0
for i in range(len(t)):
num1 += t[1::2].count("1")
t = t[1:]
print(max(num, num1))
| Statement
Takahashi has an empty string S and a variable x whose initial value is 0.
Also, we have a string T consisting of `0` and `1`.
Now, Takahashi will do the operation with the following two steps |T| times.
* Insert a `0` or a `1` at any position of S of his choice.
* Then, increment x by the sum of the digits in the odd positions (first, third, fifth, ...) of S. For example, if S is `01101`, the digits in the odd positions are `0`, `1`, `1` from left to right, so x is incremented by 2.
Print the maximum possible final value of x in a sequence of operations such
that S equals T in the end. | [{"input": "1101", "output": "5\n \n\nBelow is one sequence of operations that maximizes the final value of x to 5.\n\n * Insert a `1` at the beginning of S. S becomes `1`, and x is incremented by 1.\n * Insert a `0` to the immediate right of the first character of S. S becomes `10`, and x is incremented by 1.\n * Insert a `1` to the immediate right of the second character of S. S becomes `101`, and x is incremented by 2.\n * Insert a `1` at the beginning of S. S becomes `1101`, and x is incremented by 1.\n\n* * *"}, {"input": "0111101101", "output": "26"}] |
Print the maximum possible final value of x in a sequence of operations such
that S equals T in the end.
* * * | s621376356 | Wrong Answer | p02667 | Input is given from Standard Input in the following format:
T | def getpoint(stri):
point = 0
i = 0
for a in stri:
if (i + 1) % 2 == 1 and a == "1":
point += 1
i += 1
return point
def getmax(stri):
max = 0
temp = 0
stri2 = ""
return_stri = ""
for a in range(len(stri)):
if a <= len(stri) - 1:
stri2 = stri[0:a] + stri[a + 1 :]
else:
stri2 = stri[0:a]
# print(stri2)
temp = getpoint(stri2)
if temp > max:
max = temp
return_stri = stri2
return max, return_stri
T = input()
T2 = ""
point = getpoint(T)
while True:
temp_point, T2 = getmax(T)
point += temp_point
T = T2
if len(T) == 0:
break
print(point)
| Statement
Takahashi has an empty string S and a variable x whose initial value is 0.
Also, we have a string T consisting of `0` and `1`.
Now, Takahashi will do the operation with the following two steps |T| times.
* Insert a `0` or a `1` at any position of S of his choice.
* Then, increment x by the sum of the digits in the odd positions (first, third, fifth, ...) of S. For example, if S is `01101`, the digits in the odd positions are `0`, `1`, `1` from left to right, so x is incremented by 2.
Print the maximum possible final value of x in a sequence of operations such
that S equals T in the end. | [{"input": "1101", "output": "5\n \n\nBelow is one sequence of operations that maximizes the final value of x to 5.\n\n * Insert a `1` at the beginning of S. S becomes `1`, and x is incremented by 1.\n * Insert a `0` to the immediate right of the first character of S. S becomes `10`, and x is incremented by 1.\n * Insert a `1` to the immediate right of the second character of S. S becomes `101`, and x is incremented by 2.\n * Insert a `1` at the beginning of S. S becomes `1101`, and x is incremented by 1.\n\n* * *"}, {"input": "0111101101", "output": "26"}] |
Print the maximum possible final value of x in a sequence of operations such
that S equals T in the end.
* * * | s721179723 | Wrong Answer | p02667 | Input is given from Standard Input in the following format:
T | def getBinVal(s):
v = 0
ar = list(s)
# print(ar)
# print(len(s))
for j in range(len(s)):
if j % 2 == 0:
v += int(ar[j])
# print('getdata:' + s + ' >>> ' + str(v))
return v
T = input()
n = len(T)
aT1 = list(T)
zeros = aT1.count("0")
ones = aT1.count("1")
s = ""
x = 0
# one
if ones > 0:
for i in range(ones):
s = s + "1"
x += getBinVal(s)
# zero
idx = 0
if zeros > 0:
for k in range(zeros):
idx = T.find("0", idx)
s = s[0:idx] + "0" + s[idx:]
x += getBinVal(s)
idx = idx + 1
# x+=getBinVal('11111101')
# x+=getBinVal('111101101')
# x+=getBinVal('0111101101')
print(x)
# for i in range(n):
# s=s + aT1[i]
# x+=getBinVal(s)
# aT2=list(T)
# aT2.reverse()
# s=''
# x=0
# print(aT2)
# for i in range(n):
# s=aT2[i] + s
# x+=getBinVal(s)
# print(s)
# print(x)
| Statement
Takahashi has an empty string S and a variable x whose initial value is 0.
Also, we have a string T consisting of `0` and `1`.
Now, Takahashi will do the operation with the following two steps |T| times.
* Insert a `0` or a `1` at any position of S of his choice.
* Then, increment x by the sum of the digits in the odd positions (first, third, fifth, ...) of S. For example, if S is `01101`, the digits in the odd positions are `0`, `1`, `1` from left to right, so x is incremented by 2.
Print the maximum possible final value of x in a sequence of operations such
that S equals T in the end. | [{"input": "1101", "output": "5\n \n\nBelow is one sequence of operations that maximizes the final value of x to 5.\n\n * Insert a `1` at the beginning of S. S becomes `1`, and x is incremented by 1.\n * Insert a `0` to the immediate right of the first character of S. S becomes `10`, and x is incremented by 1.\n * Insert a `1` to the immediate right of the second character of S. S becomes `101`, and x is incremented by 2.\n * Insert a `1` at the beginning of S. S becomes `1101`, and x is incremented by 1.\n\n* * *"}, {"input": "0111101101", "output": "26"}] |
Print the maximum possible final value of x in a sequence of operations such
that S equals T in the end.
* * * | s376038752 | Accepted | p02667 | Input is given from Standard Input in the following format:
T | from itertools import groupby, accumulate
def solve(t):
if t[0] == "0":
preceding_zeros = len(t)
t = t.lstrip("0")
preceding_zeros -= len(t)
else:
preceding_zeros = 0
if len(t) == 0:
return 0
grp = [(c, len(list(itr))) for c, itr in groupby(t)]
even_ones = 0
zeros_splitting_odd_ones = [preceding_zeros]
for c, cnt in grp:
if c == "1":
if cnt % 2 == 0:
even_ones += cnt
else:
even_ones += cnt - 1
zeros_splitting_odd_ones.append(0)
else:
zeros_splitting_odd_ones[-1] += cnt
# print(even_ones)
# print(zeros_splitting_odd_ones)
# 初期状態で加算されるか
ad = int(zeros_splitting_odd_ones[0] % 2 == 0)
is_added_init = [ad]
for cnt in zeros_splitting_odd_ones[1:]:
ad ^= (cnt % 2) ^ 1
is_added_init.append(ad)
is_added_init.pop()
acc_added_init = list(
accumulate(reversed(is_added_init))
) # 自分より右で、初期状態で足される1の数
acc_added_init.reverse()
odd_ones = len(is_added_init)
ans = 0
if odd_ones > 0:
# 先頭の0を全て除くまでのスコア
zso = zeros_splitting_odd_ones[0]
zso1 = zso // 2
zso0 = zso - zso1
ans += acc_added_init[0] * zso0
ans += (odd_ones - acc_added_init[0]) * zso1
# print(ans)
# 1に挟まれた0を1箇所1つずつ残して全て除くまでのスコア
ad = int(zeros_splitting_odd_ones[0] % 2 == 0)
for i in range(1, odd_ones):
zso = zeros_splitting_odd_ones[i] - 1
zso1 = zso // 2
zso0 = zso - zso1
fixed_ones = i
right_ones = odd_ones - fixed_ones
ans += fixed_ones * zso
if ad:
# 除外中の0区間の次の"1"が初期状態で足されるなら、区間を操作する直前にも足される
ans += acc_added_init[i] * zso0
ans += (right_ones - acc_added_init[i]) * zso1
else:
# 除外中の0区間の次の"1"が初期状態で足されないなら、区間を操作する直前には足される
ans += (right_ones - acc_added_init[i]) * zso0
ans += acc_added_init[i] * zso1
ad ^= zso % 2
# print(ans)
# 末尾の0を全て除くまでのスコア
ans += zeros_splitting_odd_ones[-1] * odd_ones
# print(ans)
# 1に挟まれた0を右から除いていくまでのスコア
for i in range(1, odd_ones):
left_ones = odd_ones - i
right_ones = i
ans += left_ones + (right_ones + 1) // 2
# print(ans)
# 1だけの列を1つずつ除いていくスコア
all_ones = odd_ones + even_ones
ao1 = all_ones // 2
ao0 = all_ones - ao1
ans += (ao0 * (ao0 + 1) + ao1 * (ao1 + 1)) // 2
# print(ans)
# 0を除いている間の、偶数個の1によるスコア
all_zeros = len(t) - all_ones + preceding_zeros
ans += all_zeros * (even_ones // 2)
return ans
t = input()
print(solve(t))
| Statement
Takahashi has an empty string S and a variable x whose initial value is 0.
Also, we have a string T consisting of `0` and `1`.
Now, Takahashi will do the operation with the following two steps |T| times.
* Insert a `0` or a `1` at any position of S of his choice.
* Then, increment x by the sum of the digits in the odd positions (first, third, fifth, ...) of S. For example, if S is `01101`, the digits in the odd positions are `0`, `1`, `1` from left to right, so x is incremented by 2.
Print the maximum possible final value of x in a sequence of operations such
that S equals T in the end. | [{"input": "1101", "output": "5\n \n\nBelow is one sequence of operations that maximizes the final value of x to 5.\n\n * Insert a `1` at the beginning of S. S becomes `1`, and x is incremented by 1.\n * Insert a `0` to the immediate right of the first character of S. S becomes `10`, and x is incremented by 1.\n * Insert a `1` to the immediate right of the second character of S. S becomes `101`, and x is incremented by 2.\n * Insert a `1` at the beginning of S. S becomes `1101`, and x is incremented by 1.\n\n* * *"}, {"input": "0111101101", "output": "26"}] |
Print the maximum possible final value of x in a sequence of operations such
that S equals T in the end.
* * * | s165433657 | Wrong Answer | p02667 | Input is given from Standard Input in the following format:
T | def Z():
return int(input())
def ZZ():
return [int(_) for _ in input().split()]
def main():
T = input()
output = 0
n = e = o = 0
for i in range(len(T)):
if T[i] == "1":
n += 1
if i % 2 == 0 and T[i] == "1":
o += 1
if i % 2 == 1 and T[i] == "1":
e += 1
l = []
x = y = 0
for i in range(len(T)):
if i % 2 == 0 and T[i] == "1":
x += 1
if i % 2 == 1 and T[i] == "1":
y += 1
if T[i] == "0":
l.append([o - x, e - y])
for i in range(1, (n + 1) // 2 + 1):
output += 2 * i
if n % 2 == 1:
output -= (n + 1) // 2
for i in range(len(l)):
e = o - l[i][0] + l[i][1]
o = e - l[i][1] + l[i][0]
x = o if i % 2 == 0 else e
output += x
print(output)
return
if __name__ == "__main__":
main()
| Statement
Takahashi has an empty string S and a variable x whose initial value is 0.
Also, we have a string T consisting of `0` and `1`.
Now, Takahashi will do the operation with the following two steps |T| times.
* Insert a `0` or a `1` at any position of S of his choice.
* Then, increment x by the sum of the digits in the odd positions (first, third, fifth, ...) of S. For example, if S is `01101`, the digits in the odd positions are `0`, `1`, `1` from left to right, so x is incremented by 2.
Print the maximum possible final value of x in a sequence of operations such
that S equals T in the end. | [{"input": "1101", "output": "5\n \n\nBelow is one sequence of operations that maximizes the final value of x to 5.\n\n * Insert a `1` at the beginning of S. S becomes `1`, and x is incremented by 1.\n * Insert a `0` to the immediate right of the first character of S. S becomes `10`, and x is incremented by 1.\n * Insert a `1` to the immediate right of the second character of S. S becomes `101`, and x is incremented by 2.\n * Insert a `1` at the beginning of S. S becomes `1101`, and x is incremented by 1.\n\n* * *"}, {"input": "0111101101", "output": "26"}] |
Print the maximum possible final value of x in a sequence of operations such
that S equals T in the end.
* * * | s210975440 | Wrong Answer | p02667 | Input is given from Standard Input in the following format:
T | import sys
input = sys.stdin.readline
from collections import deque
T = deque(map(int, list(input().strip())))
LEN = len(T)
E = 0
O = 0
for i in range(len(T)):
if i % 2 == 0 and T[i] == 1:
E += 1
elif i % 2 == 1 and T[i] == 1:
O += 1
ANS = 0
ERASE = 0
while T:
# print(T,ANS,O,E)
if T[0] == 0:
if ERASE == 0:
ANS += E
T.popleft()
E, O = O, E
else:
ANS += O
T.popleft()
E, O = O, E
else:
if ERASE == 0:
ANS += len(T)
T.popleft()
ERASE = 1 - ERASE
E, O = E - 1, O
else:
T.popleft()
ERASE = 1 - ERASE
E, O = E, O - 1
print(ANS)
| Statement
Takahashi has an empty string S and a variable x whose initial value is 0.
Also, we have a string T consisting of `0` and `1`.
Now, Takahashi will do the operation with the following two steps |T| times.
* Insert a `0` or a `1` at any position of S of his choice.
* Then, increment x by the sum of the digits in the odd positions (first, third, fifth, ...) of S. For example, if S is `01101`, the digits in the odd positions are `0`, `1`, `1` from left to right, so x is incremented by 2.
Print the maximum possible final value of x in a sequence of operations such
that S equals T in the end. | [{"input": "1101", "output": "5\n \n\nBelow is one sequence of operations that maximizes the final value of x to 5.\n\n * Insert a `1` at the beginning of S. S becomes `1`, and x is incremented by 1.\n * Insert a `0` to the immediate right of the first character of S. S becomes `10`, and x is incremented by 1.\n * Insert a `1` to the immediate right of the second character of S. S becomes `101`, and x is incremented by 2.\n * Insert a `1` at the beginning of S. S becomes `1101`, and x is incremented by 1.\n\n* * *"}, {"input": "0111101101", "output": "26"}] |
Print the maximum possible final value of x in a sequence of operations such
that S equals T in the end.
* * * | s894619435 | Wrong Answer | p02667 | Input is given from Standard Input in the following format:
T | T = list(map(int, input()))
# print(T)
ans = 0
for i in range(len(T)):
ans += sum(T[::2])
if 0 in T:
T.remove(0)
else:
T.pop()
print(ans)
| Statement
Takahashi has an empty string S and a variable x whose initial value is 0.
Also, we have a string T consisting of `0` and `1`.
Now, Takahashi will do the operation with the following two steps |T| times.
* Insert a `0` or a `1` at any position of S of his choice.
* Then, increment x by the sum of the digits in the odd positions (first, third, fifth, ...) of S. For example, if S is `01101`, the digits in the odd positions are `0`, `1`, `1` from left to right, so x is incremented by 2.
Print the maximum possible final value of x in a sequence of operations such
that S equals T in the end. | [{"input": "1101", "output": "5\n \n\nBelow is one sequence of operations that maximizes the final value of x to 5.\n\n * Insert a `1` at the beginning of S. S becomes `1`, and x is incremented by 1.\n * Insert a `0` to the immediate right of the first character of S. S becomes `10`, and x is incremented by 1.\n * Insert a `1` to the immediate right of the second character of S. S becomes `101`, and x is incremented by 2.\n * Insert a `1` at the beginning of S. S becomes `1101`, and x is incremented by 1.\n\n* * *"}, {"input": "0111101101", "output": "26"}] |
Print the maximum possible final value of x in a sequence of operations such
that S equals T in the end.
* * * | s917977683 | Runtime Error | p02667 | Input is given from Standard Input in the following format:
T | # import itertools
# import numpy as np
# from scipy.sparse.csgraph import minimum_spanning_tree
# from scipy.sparse import csr_matrix, coo_matrix, lil_matrix
from itertools import accumulate
def main():
T = [int(c) for c in input()]
odd = [T[i] for i in range(len(T)) if i % 2 == 0]
even = [T[i] for i in range(len(T)) if i % 2 != 0]
ret = 0
acc_odd = list(accumulate(odd))
acc_even = list(accumulate(even))
while len(acc_even) > 0:
score = 0
# print(f'odd:{odd}')
# print(f'even:{even}')
# print(f'acc_odd:{acc_odd}')
# print(f'acc_even:{acc_even}')
pos = (-1, False)
for i in range(len(odd)):
if i == 0:
x = acc_even[-1]
y = acc_odd[i] + acc_even[-1] - acc_even[i]
elif i == len(odd) - 1:
x = acc_odd[i - 1] + acc_even[-1] - acc_even[i - 1]
if len(acc_even) == len(acc_odd):
y = acc_odd[i] + acc_even[-1] - acc_even[i]
assert y == acc_odd[i]
else:
y = 0
else:
x = acc_odd[i - 1] + acc_even[-1] - acc_even[i - 1]
y = acc_odd[i] + acc_even[-1] - acc_even[i]
if x > y and x > score:
pos = (i, True)
score = x
elif y > x and y > score:
pos = (i, False)
score = y
elif x == y and x > score: # ???
# print(f'x==y=={x}!!!')
if odd[i] == 0:
pos = (i, True)
score = x
else:
pos = (i, False)
score = y
ret += score
# print(f'pos:{pos}')
# print(f'score:{score}')
assert pos[0] != -1
if pos[1]: # oddから抜く
odd_ = odd[: pos[0]]
odd_.extend(even[pos[0] :])
even_ = even[: pos[0]]
even_.extend(odd[pos[0] + 1 :])
else: # evenから抜く
odd_ = odd[: pos[0] + 1]
odd_.extend(even[pos[0] + 1 :]) # 超えた場合は空リストになるっぽい
even_ = even[: pos[0]]
even_.extend(odd[pos[0] + 1 :])
odd, even = odd_.copy(), even_.copy()
acc_odd = list(accumulate(odd))
acc_even = list(accumulate(even))
if len(odd) == 1:
ret += odd[0]
print(ret)
if __name__ == "__main__":
main()
| Statement
Takahashi has an empty string S and a variable x whose initial value is 0.
Also, we have a string T consisting of `0` and `1`.
Now, Takahashi will do the operation with the following two steps |T| times.
* Insert a `0` or a `1` at any position of S of his choice.
* Then, increment x by the sum of the digits in the odd positions (first, third, fifth, ...) of S. For example, if S is `01101`, the digits in the odd positions are `0`, `1`, `1` from left to right, so x is incremented by 2.
Print the maximum possible final value of x in a sequence of operations such
that S equals T in the end. | [{"input": "1101", "output": "5\n \n\nBelow is one sequence of operations that maximizes the final value of x to 5.\n\n * Insert a `1` at the beginning of S. S becomes `1`, and x is incremented by 1.\n * Insert a `0` to the immediate right of the first character of S. S becomes `10`, and x is incremented by 1.\n * Insert a `1` to the immediate right of the second character of S. S becomes `101`, and x is incremented by 2.\n * Insert a `1` at the beginning of S. S becomes `1101`, and x is incremented by 1.\n\n* * *"}, {"input": "0111101101", "output": "26"}] |
Print the maximum possible final value of x in a sequence of operations such
that S equals T in the end.
* * * | s953327817 | Runtime Error | p02667 | Input is given from Standard Input in the following format:
T | def check(M, a):
for i, b in enumerate(M):
a = a - int(b)
return a
def popall(M):
c = []
for i in range(0, len(M)):
if i > 0:
a = M[0:i] + M[i + 1 : :]
elif i == 0:
a = M[i + 1 : :]
c.append("".join(a))
return c
def ckall(c):
ans = []
for _, i in enumerate(c):
ans.append(check(i, 0))
return ans.index(min(ans)), c[ans.index(min(ans))]
def efun(N, a):
b = ckall(popall(N[0::2]))[0]
if int(b) > 0:
rN = N[0:b] + N[b + 1 : :]
elif int(b) == 0:
rN = N[b + 1 : :]
a = a + int(ckall(popall(N[0::2]))[1])
return rN, a
if __name__ == "__main__":
N = list(input())
a = 0
while True:
N, a = efun(N, a)
if len(N) == 2:
print("".join(N))
print(a)
break
| Statement
Takahashi has an empty string S and a variable x whose initial value is 0.
Also, we have a string T consisting of `0` and `1`.
Now, Takahashi will do the operation with the following two steps |T| times.
* Insert a `0` or a `1` at any position of S of his choice.
* Then, increment x by the sum of the digits in the odd positions (first, third, fifth, ...) of S. For example, if S is `01101`, the digits in the odd positions are `0`, `1`, `1` from left to right, so x is incremented by 2.
Print the maximum possible final value of x in a sequence of operations such
that S equals T in the end. | [{"input": "1101", "output": "5\n \n\nBelow is one sequence of operations that maximizes the final value of x to 5.\n\n * Insert a `1` at the beginning of S. S becomes `1`, and x is incremented by 1.\n * Insert a `0` to the immediate right of the first character of S. S becomes `10`, and x is incremented by 1.\n * Insert a `1` to the immediate right of the second character of S. S becomes `101`, and x is incremented by 2.\n * Insert a `1` at the beginning of S. S becomes `1101`, and x is incremented by 1.\n\n* * *"}, {"input": "0111101101", "output": "26"}] |
Print the maximum possible final value of x in a sequence of operations such
that S equals T in the end.
* * * | s544804229 | Wrong Answer | p02667 | Input is given from Standard Input in the following format:
T | input()
print(1)
| Statement
Takahashi has an empty string S and a variable x whose initial value is 0.
Also, we have a string T consisting of `0` and `1`.
Now, Takahashi will do the operation with the following two steps |T| times.
* Insert a `0` or a `1` at any position of S of his choice.
* Then, increment x by the sum of the digits in the odd positions (first, third, fifth, ...) of S. For example, if S is `01101`, the digits in the odd positions are `0`, `1`, `1` from left to right, so x is incremented by 2.
Print the maximum possible final value of x in a sequence of operations such
that S equals T in the end. | [{"input": "1101", "output": "5\n \n\nBelow is one sequence of operations that maximizes the final value of x to 5.\n\n * Insert a `1` at the beginning of S. S becomes `1`, and x is incremented by 1.\n * Insert a `0` to the immediate right of the first character of S. S becomes `10`, and x is incremented by 1.\n * Insert a `1` to the immediate right of the second character of S. S becomes `101`, and x is incremented by 2.\n * Insert a `1` at the beginning of S. S becomes `1101`, and x is incremented by 1.\n\n* * *"}, {"input": "0111101101", "output": "26"}] |
Print the maximum possible final value of x in a sequence of operations such
that S equals T in the end.
* * * | s378382989 | Accepted | p02667 | Input is given from Standard Input in the following format:
T | t = input()
n = len(t)
pos = []
sum = 0
for i in range(n):
if t[i] == "1":
sum += 1
else:
pos.append(sum)
x = (sum + 1) // 2 * ((sum + 2) // 2)
sz = len(pos)
cnt = 0
res = []
for i in range(sz):
if (pos[i] & 1) ^ (cnt & 1):
sum += 1
cnt += 1
x += (sum + 1) // 2
else:
res.append(i)
res = res[::-1]
odd = 0
even = 0
for i in range(len(res)):
sum += 1
if i & 1:
odd = sz - res[i] - even
x += (sum + 1) // 2 - odd
else:
even = sz - res[i] - odd
x += (sum + 1) // 2 - even
print(x)
| Statement
Takahashi has an empty string S and a variable x whose initial value is 0.
Also, we have a string T consisting of `0` and `1`.
Now, Takahashi will do the operation with the following two steps |T| times.
* Insert a `0` or a `1` at any position of S of his choice.
* Then, increment x by the sum of the digits in the odd positions (first, third, fifth, ...) of S. For example, if S is `01101`, the digits in the odd positions are `0`, `1`, `1` from left to right, so x is incremented by 2.
Print the maximum possible final value of x in a sequence of operations such
that S equals T in the end. | [{"input": "1101", "output": "5\n \n\nBelow is one sequence of operations that maximizes the final value of x to 5.\n\n * Insert a `1` at the beginning of S. S becomes `1`, and x is incremented by 1.\n * Insert a `0` to the immediate right of the first character of S. S becomes `10`, and x is incremented by 1.\n * Insert a `1` to the immediate right of the second character of S. S becomes `101`, and x is incremented by 2.\n * Insert a `1` at the beginning of S. S becomes `1101`, and x is incremented by 1.\n\n* * *"}, {"input": "0111101101", "output": "26"}] |
Print the number of classes you can attend.
* * * | s500791435 | Accepted | p03975 | N, A and B are given on the first line and t_i is given on the (i+1)-th line.
N A B
t1
:
tN | line = input().split()
N, A, B = int(line[0]), int(line[1]), int(line[2])
minus = 0
for i in range(N):
if A <= int(input()) < B:
minus += 1
print(N - minus)
| Statement
Summer vacation ended at last and the second semester has begun. You, a Kyoto
University student, came to university and heard a rumor that somebody will
barricade the entrance of your classroom. The barricade will be built just
before the start of the A-th class and removed by Kyoto University students
just before the start of the B-th class. All the classes conducted when the
barricade is blocking the entrance will be cancelled and you will not be able
to attend them. Today you take N classes and class i is conducted in the t_i-
th period. You take at most one class in each period. Find the number of
classes you can attend. | [{"input": "5 5 9\n 4\n 3\n 6\n 9\n 1", "output": "4\n \n\nYou can not only attend the third class."}, {"input": "5 4 9\n 5\n 6\n 7\n 8\n 9", "output": "1\n \n\nYou can only attend the fifth class."}, {"input": "4 3 6\n 9\n 6\n 8\n 1", "output": "4\n \n\nYou can attend all the classes."}, {"input": "2 1 2\n 1\n 2", "output": "1\n \n\nYou can not attend the first class, but can attend the second."}] |
Print the number of classes you can attend.
* * * | s435117688 | Accepted | p03975 | N, A and B are given on the first line and t_i is given on the (i+1)-th line.
N A B
t1
:
tN | # -*- coding: utf-8 -*-
import sys
from bisect import bisect_left
def input():
return sys.stdin.readline().strip()
def list2d(a, b, c):
return [[c] * b for i in range(a)]
def list3d(a, b, c, d):
return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e):
return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1):
return int(-(-x // y))
def INT():
return int(input())
def MAP():
return map(int, input().split())
def LIST(N=None):
return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes():
print("Yes")
def No():
print("No")
def YES():
print("YES")
def NO():
print("NO")
sys.setrecursionlimit(10**9)
INF = float("inf")
MOD = 10**9 + 7
N, s, t = MAP()
A = LIST(N)
A.sort()
l = bisect_left(A, s)
r = bisect_left(A, t)
print(N - (r - l))
| Statement
Summer vacation ended at last and the second semester has begun. You, a Kyoto
University student, came to university and heard a rumor that somebody will
barricade the entrance of your classroom. The barricade will be built just
before the start of the A-th class and removed by Kyoto University students
just before the start of the B-th class. All the classes conducted when the
barricade is blocking the entrance will be cancelled and you will not be able
to attend them. Today you take N classes and class i is conducted in the t_i-
th period. You take at most one class in each period. Find the number of
classes you can attend. | [{"input": "5 5 9\n 4\n 3\n 6\n 9\n 1", "output": "4\n \n\nYou can not only attend the third class."}, {"input": "5 4 9\n 5\n 6\n 7\n 8\n 9", "output": "1\n \n\nYou can only attend the fifth class."}, {"input": "4 3 6\n 9\n 6\n 8\n 1", "output": "4\n \n\nYou can attend all the classes."}, {"input": "2 1 2\n 1\n 2", "output": "1\n \n\nYou can not attend the first class, but can attend the second."}] |
Print the number of classes you can attend.
* * * | s445525891 | Wrong Answer | p03975 | N, A and B are given on the first line and t_i is given on the (i+1)-th line.
N A B
t1
:
tN | n, a, b = map(int, input().split())
kazu = 0
for cl in range(n):
jugyo = int(input())
if a >= jugyo or jugyo >= b:
kazu += 1
print(kazu)
| Statement
Summer vacation ended at last and the second semester has begun. You, a Kyoto
University student, came to university and heard a rumor that somebody will
barricade the entrance of your classroom. The barricade will be built just
before the start of the A-th class and removed by Kyoto University students
just before the start of the B-th class. All the classes conducted when the
barricade is blocking the entrance will be cancelled and you will not be able
to attend them. Today you take N classes and class i is conducted in the t_i-
th period. You take at most one class in each period. Find the number of
classes you can attend. | [{"input": "5 5 9\n 4\n 3\n 6\n 9\n 1", "output": "4\n \n\nYou can not only attend the third class."}, {"input": "5 4 9\n 5\n 6\n 7\n 8\n 9", "output": "1\n \n\nYou can only attend the fifth class."}, {"input": "4 3 6\n 9\n 6\n 8\n 1", "output": "4\n \n\nYou can attend all the classes."}, {"input": "2 1 2\n 1\n 2", "output": "1\n \n\nYou can not attend the first class, but can attend the second."}] |
Print the number of classes you can attend.
* * * | s847754459 | Runtime Error | p03975 | N, A and B are given on the first line and t_i is given on the (i+1)-th line.
N A B
t1
:
tN | n, a, b = map(int, input().split())
2.kazu = 0
3.for cl in range(n):
4. jugyo = int(input())
5. if a > jugyo or jugyo >= b:
6. kazu += 1
7.print(kazu)
| Statement
Summer vacation ended at last and the second semester has begun. You, a Kyoto
University student, came to university and heard a rumor that somebody will
barricade the entrance of your classroom. The barricade will be built just
before the start of the A-th class and removed by Kyoto University students
just before the start of the B-th class. All the classes conducted when the
barricade is blocking the entrance will be cancelled and you will not be able
to attend them. Today you take N classes and class i is conducted in the t_i-
th period. You take at most one class in each period. Find the number of
classes you can attend. | [{"input": "5 5 9\n 4\n 3\n 6\n 9\n 1", "output": "4\n \n\nYou can not only attend the third class."}, {"input": "5 4 9\n 5\n 6\n 7\n 8\n 9", "output": "1\n \n\nYou can only attend the fifth class."}, {"input": "4 3 6\n 9\n 6\n 8\n 1", "output": "4\n \n\nYou can attend all the classes."}, {"input": "2 1 2\n 1\n 2", "output": "1\n \n\nYou can not attend the first class, but can attend the second."}] |
Print the number of classes you can attend.
* * * | s126084057 | Accepted | p03975 | N, A and B are given on the first line and t_i is given on the (i+1)-th line.
N A B
t1
:
tN | N, A, B = map(int, input().split())
t = [(A <= int(input()) < B) for i in range(N)]
print(t.count(False))
| Statement
Summer vacation ended at last and the second semester has begun. You, a Kyoto
University student, came to university and heard a rumor that somebody will
barricade the entrance of your classroom. The barricade will be built just
before the start of the A-th class and removed by Kyoto University students
just before the start of the B-th class. All the classes conducted when the
barricade is blocking the entrance will be cancelled and you will not be able
to attend them. Today you take N classes and class i is conducted in the t_i-
th period. You take at most one class in each period. Find the number of
classes you can attend. | [{"input": "5 5 9\n 4\n 3\n 6\n 9\n 1", "output": "4\n \n\nYou can not only attend the third class."}, {"input": "5 4 9\n 5\n 6\n 7\n 8\n 9", "output": "1\n \n\nYou can only attend the fifth class."}, {"input": "4 3 6\n 9\n 6\n 8\n 1", "output": "4\n \n\nYou can attend all the classes."}, {"input": "2 1 2\n 1\n 2", "output": "1\n \n\nYou can not attend the first class, but can attend the second."}] |
Print the number of classes you can attend.
* * * | s970140504 | Accepted | p03975 | N, A and B are given on the first line and t_i is given on the (i+1)-th line.
N A B
t1
:
tN | n, a, b, *s = map(int, open(0).read().split())
print(sum(t < a or b <= t for t in s))
| Statement
Summer vacation ended at last and the second semester has begun. You, a Kyoto
University student, came to university and heard a rumor that somebody will
barricade the entrance of your classroom. The barricade will be built just
before the start of the A-th class and removed by Kyoto University students
just before the start of the B-th class. All the classes conducted when the
barricade is blocking the entrance will be cancelled and you will not be able
to attend them. Today you take N classes and class i is conducted in the t_i-
th period. You take at most one class in each period. Find the number of
classes you can attend. | [{"input": "5 5 9\n 4\n 3\n 6\n 9\n 1", "output": "4\n \n\nYou can not only attend the third class."}, {"input": "5 4 9\n 5\n 6\n 7\n 8\n 9", "output": "1\n \n\nYou can only attend the fifth class."}, {"input": "4 3 6\n 9\n 6\n 8\n 1", "output": "4\n \n\nYou can attend all the classes."}, {"input": "2 1 2\n 1\n 2", "output": "1\n \n\nYou can not attend the first class, but can attend the second."}] |
Print the answer.
* * * | s095100640 | Accepted | p02688 | Input is given from Standard Input in the following format:
N K
d_1
A_{1, 1} \cdots A_{1, d_1}
\vdots
d_K
A_{K, 1} \cdots A_{K, d_K} | import sys
from collections import deque
sys.setrecursionlimit(10**6)
def S():
return sys.stdin.readline().rstrip()
def SL():
return map(str, sys.stdin.readline().rstrip().split())
def I():
return int(sys.stdin.readline().rstrip())
def IL():
return map(int, sys.stdin.readline().rstrip().split())
def LS():
return list(sys.stdin.readline().rstrip().split())
def LI():
return list(map(int, sys.stdin.readline().rstrip().split()))
def Main():
n, k = IL()
s = [0] * n
d = deque()
for __ in range(k):
d = I()
tmp = deque(LI())
for _ in range(d):
s[tmp.pop() - 1] += 1
print(s.count(0))
return
if __name__ == "__main__":
Main()
| Statement
N _Snukes_ called Snuke 1, Snuke 2, ..., Snuke N live in a town.
There are K kinds of snacks sold in this town, called Snack 1, Snack 2, ...,
Snack K. The following d_i Snukes have Snack i: Snuke A_{i, 1}, A_{i, 2},
\cdots, A_{i, {d_i}}.
Takahashi will walk around this town and make mischief on the Snukes who have
no snacks. How many Snukes will fall victim to Takahashi's mischief? | [{"input": "3 2\n 2\n 1 3\n 1\n 3", "output": "1\n \n\n * Snuke 1 has Snack 1.\n * Snuke 2 has no snacks.\n * Snuke 3 has Snack 1 and 2.\n\nThus, there will be one victim: Snuke 2.\n\n* * *"}, {"input": "3 3\n 1\n 3\n 1\n 3\n 1\n 3", "output": "2"}] |
Print the answer.
* * * | s648587149 | Runtime Error | p02688 | Input is given from Standard Input in the following format:
N K
d_1
A_{1, 1} \cdots A_{1, d_1}
\vdots
d_K
A_{K, 1} \cdots A_{K, d_K} | N = int(input())
ans = set([input() for _ in range(N)])
print(len(ans))
| Statement
N _Snukes_ called Snuke 1, Snuke 2, ..., Snuke N live in a town.
There are K kinds of snacks sold in this town, called Snack 1, Snack 2, ...,
Snack K. The following d_i Snukes have Snack i: Snuke A_{i, 1}, A_{i, 2},
\cdots, A_{i, {d_i}}.
Takahashi will walk around this town and make mischief on the Snukes who have
no snacks. How many Snukes will fall victim to Takahashi's mischief? | [{"input": "3 2\n 2\n 1 3\n 1\n 3", "output": "1\n \n\n * Snuke 1 has Snack 1.\n * Snuke 2 has no snacks.\n * Snuke 3 has Snack 1 and 2.\n\nThus, there will be one victim: Snuke 2.\n\n* * *"}, {"input": "3 3\n 1\n 3\n 1\n 3\n 1\n 3", "output": "2"}] |
Print the answer.
* * * | s552341409 | Runtime Error | p02688 | Input is given from Standard Input in the following format:
N K
d_1
A_{1, 1} \cdots A_{1, d_1}
\vdots
d_K
A_{K, 1} \cdots A_{K, d_K} | a, b, c, d, e, f, g = (int(x) for x in input().split())
print(a - c)
| Statement
N _Snukes_ called Snuke 1, Snuke 2, ..., Snuke N live in a town.
There are K kinds of snacks sold in this town, called Snack 1, Snack 2, ...,
Snack K. The following d_i Snukes have Snack i: Snuke A_{i, 1}, A_{i, 2},
\cdots, A_{i, {d_i}}.
Takahashi will walk around this town and make mischief on the Snukes who have
no snacks. How many Snukes will fall victim to Takahashi's mischief? | [{"input": "3 2\n 2\n 1 3\n 1\n 3", "output": "1\n \n\n * Snuke 1 has Snack 1.\n * Snuke 2 has no snacks.\n * Snuke 3 has Snack 1 and 2.\n\nThus, there will be one victim: Snuke 2.\n\n* * *"}, {"input": "3 3\n 1\n 3\n 1\n 3\n 1\n 3", "output": "2"}] |
Print the answer.
* * * | s534848864 | Runtime Error | p02688 | Input is given from Standard Input in the following format:
N K
d_1
A_{1, 1} \cdots A_{1, d_1}
\vdots
d_K
A_{K, 1} \cdots A_{K, d_K} | N, K = (int(x) for x in input().split())
lists = [0] * N
while 1:
tmp = int(input())
if not tmp:
break
have_count = (int(x) for x in input().split())
for i in have_count:
lists[i - 1] = 1
print(lists.count(0))
| Statement
N _Snukes_ called Snuke 1, Snuke 2, ..., Snuke N live in a town.
There are K kinds of snacks sold in this town, called Snack 1, Snack 2, ...,
Snack K. The following d_i Snukes have Snack i: Snuke A_{i, 1}, A_{i, 2},
\cdots, A_{i, {d_i}}.
Takahashi will walk around this town and make mischief on the Snukes who have
no snacks. How many Snukes will fall victim to Takahashi's mischief? | [{"input": "3 2\n 2\n 1 3\n 1\n 3", "output": "1\n \n\n * Snuke 1 has Snack 1.\n * Snuke 2 has no snacks.\n * Snuke 3 has Snack 1 and 2.\n\nThus, there will be one victim: Snuke 2.\n\n* * *"}, {"input": "3 3\n 1\n 3\n 1\n 3\n 1\n 3", "output": "2"}] |
Print the answer.
* * * | s794846626 | Wrong Answer | p02688 | Input is given from Standard Input in the following format:
N K
d_1
A_{1, 1} \cdots A_{1, d_1}
\vdots
d_K
A_{K, 1} \cdots A_{K, d_K} | def l():
return [int(a) for a in input().split(" ")]
ka = l()
lis = [a + 1 for a in range(ka[0])]
input()
for a in range(ka[1]):
q = l()
for b in q:
if b in lis:
lis.pop(lis.index(b))
print(len(lis))
| Statement
N _Snukes_ called Snuke 1, Snuke 2, ..., Snuke N live in a town.
There are K kinds of snacks sold in this town, called Snack 1, Snack 2, ...,
Snack K. The following d_i Snukes have Snack i: Snuke A_{i, 1}, A_{i, 2},
\cdots, A_{i, {d_i}}.
Takahashi will walk around this town and make mischief on the Snukes who have
no snacks. How many Snukes will fall victim to Takahashi's mischief? | [{"input": "3 2\n 2\n 1 3\n 1\n 3", "output": "1\n \n\n * Snuke 1 has Snack 1.\n * Snuke 2 has no snacks.\n * Snuke 3 has Snack 1 and 2.\n\nThus, there will be one victim: Snuke 2.\n\n* * *"}, {"input": "3 3\n 1\n 3\n 1\n 3\n 1\n 3", "output": "2"}] |
Print the answer.
* * * | s225536096 | Accepted | p02688 | Input is given from Standard Input in the following format:
N K
d_1
A_{1, 1} \cdots A_{1, d_1}
\vdots
d_K
A_{K, 1} \cdots A_{K, d_K} | num = input().split(" ")
people = int(num[0])
kind = int(num[1])
sunuke = []
for i in range(kind):
have = int(input())
a = input().split(" ")
for j in range(have):
sunuke.append(a[j])
print(people - len(set(sunuke)))
| Statement
N _Snukes_ called Snuke 1, Snuke 2, ..., Snuke N live in a town.
There are K kinds of snacks sold in this town, called Snack 1, Snack 2, ...,
Snack K. The following d_i Snukes have Snack i: Snuke A_{i, 1}, A_{i, 2},
\cdots, A_{i, {d_i}}.
Takahashi will walk around this town and make mischief on the Snukes who have
no snacks. How many Snukes will fall victim to Takahashi's mischief? | [{"input": "3 2\n 2\n 1 3\n 1\n 3", "output": "1\n \n\n * Snuke 1 has Snack 1.\n * Snuke 2 has no snacks.\n * Snuke 3 has Snack 1 and 2.\n\nThus, there will be one victim: Snuke 2.\n\n* * *"}, {"input": "3 3\n 1\n 3\n 1\n 3\n 1\n 3", "output": "2"}] |
Print the answer.
* * * | s485004724 | Accepted | p02688 | Input is given from Standard Input in the following format:
N K
d_1
A_{1, 1} \cdots A_{1, d_1}
\vdots
d_K
A_{K, 1} \cdots A_{K, d_K} | n, k = map(int, input().split())
d = [[] for i in range(k)]
dlist = []
memb = [i + 1 for i in range(n)]
for i in range(k):
d[i] = int(input())
dklist = list(map(int, input().split()))
dlist.append(dklist)
for j in dklist:
if j in memb:
memb.remove(j)
print(len(list(memb)))
| Statement
N _Snukes_ called Snuke 1, Snuke 2, ..., Snuke N live in a town.
There are K kinds of snacks sold in this town, called Snack 1, Snack 2, ...,
Snack K. The following d_i Snukes have Snack i: Snuke A_{i, 1}, A_{i, 2},
\cdots, A_{i, {d_i}}.
Takahashi will walk around this town and make mischief on the Snukes who have
no snacks. How many Snukes will fall victim to Takahashi's mischief? | [{"input": "3 2\n 2\n 1 3\n 1\n 3", "output": "1\n \n\n * Snuke 1 has Snack 1.\n * Snuke 2 has no snacks.\n * Snuke 3 has Snack 1 and 2.\n\nThus, there will be one victim: Snuke 2.\n\n* * *"}, {"input": "3 3\n 1\n 3\n 1\n 3\n 1\n 3", "output": "2"}] |
Print the answer.
* * * | s935640378 | Accepted | p02688 | Input is given from Standard Input in the following format:
N K
d_1
A_{1, 1} \cdots A_{1, d_1}
\vdots
d_K
A_{K, 1} \cdots A_{K, d_K} | a, b = map(int, input().split())
lis = [0] * a
for i in range(b):
p = int(input())
t = map(int, input().split())
for j in t:
lis[j - 1] = 1
for i in lis:
a -= i
print(a)
| Statement
N _Snukes_ called Snuke 1, Snuke 2, ..., Snuke N live in a town.
There are K kinds of snacks sold in this town, called Snack 1, Snack 2, ...,
Snack K. The following d_i Snukes have Snack i: Snuke A_{i, 1}, A_{i, 2},
\cdots, A_{i, {d_i}}.
Takahashi will walk around this town and make mischief on the Snukes who have
no snacks. How many Snukes will fall victim to Takahashi's mischief? | [{"input": "3 2\n 2\n 1 3\n 1\n 3", "output": "1\n \n\n * Snuke 1 has Snack 1.\n * Snuke 2 has no snacks.\n * Snuke 3 has Snack 1 and 2.\n\nThus, there will be one victim: Snuke 2.\n\n* * *"}, {"input": "3 3\n 1\n 3\n 1\n 3\n 1\n 3", "output": "2"}] |
Print the answer.
* * * | s940404303 | Wrong Answer | p02688 | Input is given from Standard Input in the following format:
N K
d_1
A_{1, 1} \cdots A_{1, d_1}
\vdots
d_K
A_{K, 1} \cdots A_{K, d_K} | N, K = map(int, input().split())
m = []
for i in range(K-1):
di = int(input())
A = [int(d) for d in input().split()]
m = m + A
M = list(set(m))
print(N - len(M)) | Statement
N _Snukes_ called Snuke 1, Snuke 2, ..., Snuke N live in a town.
There are K kinds of snacks sold in this town, called Snack 1, Snack 2, ...,
Snack K. The following d_i Snukes have Snack i: Snuke A_{i, 1}, A_{i, 2},
\cdots, A_{i, {d_i}}.
Takahashi will walk around this town and make mischief on the Snukes who have
no snacks. How many Snukes will fall victim to Takahashi's mischief? | [{"input": "3 2\n 2\n 1 3\n 1\n 3", "output": "1\n \n\n * Snuke 1 has Snack 1.\n * Snuke 2 has no snacks.\n * Snuke 3 has Snack 1 and 2.\n\nThus, there will be one victim: Snuke 2.\n\n* * *"}, {"input": "3 3\n 1\n 3\n 1\n 3\n 1\n 3", "output": "2"}] |
Print the answer.
* * * | s089343421 | Accepted | p02688 | Input is given from Standard Input in the following format:
N K
d_1
A_{1, 1} \cdots A_{1, d_1}
\vdots
d_K
A_{K, 1} \cdots A_{K, d_K} | x, *l = open(0)
print(int(x.split()[0]) - len({*"".join(l[1::2]).split()}))
| Statement
N _Snukes_ called Snuke 1, Snuke 2, ..., Snuke N live in a town.
There are K kinds of snacks sold in this town, called Snack 1, Snack 2, ...,
Snack K. The following d_i Snukes have Snack i: Snuke A_{i, 1}, A_{i, 2},
\cdots, A_{i, {d_i}}.
Takahashi will walk around this town and make mischief on the Snukes who have
no snacks. How many Snukes will fall victim to Takahashi's mischief? | [{"input": "3 2\n 2\n 1 3\n 1\n 3", "output": "1\n \n\n * Snuke 1 has Snack 1.\n * Snuke 2 has no snacks.\n * Snuke 3 has Snack 1 and 2.\n\nThus, there will be one victim: Snuke 2.\n\n* * *"}, {"input": "3 3\n 1\n 3\n 1\n 3\n 1\n 3", "output": "2"}] |
Print the answer.
* * * | s715702946 | Wrong Answer | p02688 | Input is given from Standard Input in the following format:
N K
d_1
A_{1, 1} \cdots A_{1, d_1}
\vdots
d_K
A_{K, 1} \cdots A_{K, d_K} | n, *t = open(0)
print(int(n[:2]) - len({*"".join(t[1::2]).split()}))
| Statement
N _Snukes_ called Snuke 1, Snuke 2, ..., Snuke N live in a town.
There are K kinds of snacks sold in this town, called Snack 1, Snack 2, ...,
Snack K. The following d_i Snukes have Snack i: Snuke A_{i, 1}, A_{i, 2},
\cdots, A_{i, {d_i}}.
Takahashi will walk around this town and make mischief on the Snukes who have
no snacks. How many Snukes will fall victim to Takahashi's mischief? | [{"input": "3 2\n 2\n 1 3\n 1\n 3", "output": "1\n \n\n * Snuke 1 has Snack 1.\n * Snuke 2 has no snacks.\n * Snuke 3 has Snack 1 and 2.\n\nThus, there will be one victim: Snuke 2.\n\n* * *"}, {"input": "3 3\n 1\n 3\n 1\n 3\n 1\n 3", "output": "2"}] |
Print the answer.
* * * | s183189046 | Accepted | p02688 | Input is given from Standard Input in the following format:
N K
d_1
A_{1, 1} \cdots A_{1, d_1}
\vdots
d_K
A_{K, 1} \cdots A_{K, d_K} | """
ある街に、N 人のすぬけ君(すぬけ君 1 、すぬけ君 2 、 ...、 すぬけ君 N)が住んでいます。
この街には、 K種類のお菓子(お菓子 1 、 お菓子 2 、....、お菓子 K )が売られています。
お菓子 i を持っているのは、すぬけ君 Ai,1,Ai,2,⋯,Ai,di の計 di人です。
高橋君は今からこの街を回り、お菓子を 1つも持っていないすぬけ君にいたずらをします。
このとき、何人のすぬけ君がいたずらを受けるでしょうか。
制約
入力は全て整数
1≤N≤100
1≤K≤100
1≤di≤N
1≤Ai,1<⋯<Ai,di≤N
"""
n, k = map(int, input().split())
a = [[] for ii in range(k)]
d = [0] * k
r = [1] * n
for ii in range(k):
d[ii] = int(input())
a[ii] = [] * d[ii]
a[ii][:] = map(int, input().split())
for jj in range(d[ii]):
r[a[ii][jj] - 1] = 0
print(sum(r))
| Statement
N _Snukes_ called Snuke 1, Snuke 2, ..., Snuke N live in a town.
There are K kinds of snacks sold in this town, called Snack 1, Snack 2, ...,
Snack K. The following d_i Snukes have Snack i: Snuke A_{i, 1}, A_{i, 2},
\cdots, A_{i, {d_i}}.
Takahashi will walk around this town and make mischief on the Snukes who have
no snacks. How many Snukes will fall victim to Takahashi's mischief? | [{"input": "3 2\n 2\n 1 3\n 1\n 3", "output": "1\n \n\n * Snuke 1 has Snack 1.\n * Snuke 2 has no snacks.\n * Snuke 3 has Snack 1 and 2.\n\nThus, there will be one victim: Snuke 2.\n\n* * *"}, {"input": "3 3\n 1\n 3\n 1\n 3\n 1\n 3", "output": "2"}] |
Print the answer.
* * * | s089143801 | Runtime Error | p02688 | Input is given from Standard Input in the following format:
N K
d_1
A_{1, 1} \cdots A_{1, d_1}
\vdots
d_K
A_{K, 1} \cdots A_{K, d_K} | n = input().split()
N = int(n[0])
K = int(n[1])
s = [list(map(int, input().split())) for i in range(2 * K + 1)]
b = list(range(N))
for l in b:
for i in range(K):
di = s[2 * i]
ai = s[2 * i + 1]
for k in ai:
if k == l:
b.remove(l)
ai.remove(l)
print(len(b))
| Statement
N _Snukes_ called Snuke 1, Snuke 2, ..., Snuke N live in a town.
There are K kinds of snacks sold in this town, called Snack 1, Snack 2, ...,
Snack K. The following d_i Snukes have Snack i: Snuke A_{i, 1}, A_{i, 2},
\cdots, A_{i, {d_i}}.
Takahashi will walk around this town and make mischief on the Snukes who have
no snacks. How many Snukes will fall victim to Takahashi's mischief? | [{"input": "3 2\n 2\n 1 3\n 1\n 3", "output": "1\n \n\n * Snuke 1 has Snack 1.\n * Snuke 2 has no snacks.\n * Snuke 3 has Snack 1 and 2.\n\nThus, there will be one victim: Snuke 2.\n\n* * *"}, {"input": "3 3\n 1\n 3\n 1\n 3\n 1\n 3", "output": "2"}] |
Print the number of choices of K in which N becomes 1 in the end.
* * * | s348815847 | Accepted | p02722 | Input is given from Standard Input in the following format:
N | n = int(input())
set_ans = {n}
for x in range(2, int(n**0.5) + 1):
if n % x == 0:
tmp = n
while tmp % x == 0:
tmp //= x
if tmp % x == 1:
set_ans.add(x)
for x in range(1, int((n - 1) ** 0.5) + 1):
if (n - 1) % x == 0:
if x > 1:
set_ans.add(x)
if (n - 1) // x != x:
set_ans.add((n - 1) // x)
print(len(set_ans))
| Statement
Given is a positive integer N.
We will choose an integer K between 2 and N (inclusive), then we will repeat
the operation below until N becomes less than K.
* Operation: if K divides N, replace N with N/K; otherwise, replace N with N-K.
In how many choices of K will N become 1 in the end? | [{"input": "6", "output": "3\n \n\nThere are three choices of K in which N becomes 1 in the end: 2, 5, and 6.\n\nIn each of these choices, N will change as follows:\n\n * When K=2: 6 \\to 3 \\to 1\n * When K=5: 6 \\to 1\n * When K=6: 6 \\to 1\n\n* * *"}, {"input": "3141", "output": "13\n \n\n* * *"}, {"input": "314159265358", "output": "9"}] |
Print the number of choices of K in which N becomes 1 in the end.
* * * | s625365991 | Runtime Error | p02722 | Input is given from Standard Input in the following format:
N | #!usr/bin/env python3
import sys
import math
import collections
import numpy as np
MOD = 10**9 + 7
INF = float("inf")
input = lambda: sys.stdin.readline().strip()
sys.setrecursionlimit(10**8)
def prime_factorization(n):
"""
nを素因数分解したリストを返す。
n >= 2
"""
ans = []
for i in range(2, int(math.sqrt(n) + 2)):
if n % i == 0:
while n % i == 0:
ans.append(i)
n //= i
if n != 1:
ans.append(n)
return ans
N = int(input())
ans = 0
primes = prime_factorization(N)
prime_temp = []
primes2 = prime_factorization(N - 1)
List = []
for i in range(2 ** (len(primes2))):
temp = []
for j in range(len(primes2)):
prid = np.prod([primes2[j] if i & (1 << j) else 1 for j in range(len(primes2))])
if prid != 1:
List.append(prid)
for i in range(2 ** (len(primes))):
temp = []
for j in range(len(primes)):
if i & (1 << j):
temp.append(primes[j])
temp2 = 1
if len(temp) > 1:
for l in temp:
temp2 *= l
prime_temp.append(temp2)
List = list(set(List))
a = collections.Counter(primes)
prime_set = list(set(primes + prime_temp))
for i in prime_set:
if a[i] != 1:
num = a[i]
for j in range(2, num + 1):
prime_set.append(i**j)
for i in prime_set:
temp = N
while temp % i == 0:
temp //= i
if temp % i == 1:
List.append(i)
List = list(set(List))
print(len(List) + 1 if N not in List else len(List))
| Statement
Given is a positive integer N.
We will choose an integer K between 2 and N (inclusive), then we will repeat
the operation below until N becomes less than K.
* Operation: if K divides N, replace N with N/K; otherwise, replace N with N-K.
In how many choices of K will N become 1 in the end? | [{"input": "6", "output": "3\n \n\nThere are three choices of K in which N becomes 1 in the end: 2, 5, and 6.\n\nIn each of these choices, N will change as follows:\n\n * When K=2: 6 \\to 3 \\to 1\n * When K=5: 6 \\to 1\n * When K=6: 6 \\to 1\n\n* * *"}, {"input": "3141", "output": "13\n \n\n* * *"}, {"input": "314159265358", "output": "9"}] |
Print the number of choices of K in which N becomes 1 in the end.
* * * | s108547843 | Runtime Error | p02722 | Input is given from Standard Input in the following format:
N | import numpy as np
N, M = map(int, input().split())
ABC = np.zeros((N, 3))
for i in range(N):
ABC[i][0], ABC[i][1], ABC[i][2] = map(int, input().split())
DEF = np.zeros((M, 3))
for i in range(M):
DEF[i][0], DEF[i][1], DEF[i][2] = map(int, input().split())
# 座標圧縮
x_co = {-(10**9) - 1, 10**9 + 1}
y_co = {-(10**9) - 1, 10**9 + 1}
for i in range(N):
x_co.add(ABC[i][0])
x_co.add(ABC[i][1])
y_co.add(ABC[i][2])
for i in range(M):
x_co.add(DEF[i][0])
y_co.add(DEF[i][1])
y_co.add(DEF[i][2])
x_co = np.array(sorted(list(x_co)))
y_co = np.array(sorted(list(y_co)))
xL = len(x_co) - 1
yL = len(y_co) - 1
x_co_d = {x_co[i]: i for i in range(xL + 1)}
y_co_d = {y_co[i]: i for i in range(yL + 1)}
# 柵の存在
s_ex_tate = np.zeros((yL + 1, xL))
s_ex_yoko = np.zeros((xL + 1, yL))
for i in range(N):
a = x_co_d[ABC[i][0]]
b = x_co_d[ABC[i][1]]
c = y_co_d[ABC[i][2]]
s_ex_tate[c][a:b] = 1
for i in range(M):
d = x_co_d[DEF[i][0]]
e = y_co_d[DEF[i][1]]
f = y_co_d[DEF[i][2]]
s_ex_yoko[d][e:f] = 1
# 初期位置
for i in range(xL):
if x_co[i + 1] > 0:
xf = [i]
break
if x_co[i + 1] == 0:
xf = [i, i + 1]
break
for i in range(yL):
if y_co[i + 1] > 0:
yf = [i]
break
if y_co[i + 1] == 0:
yf = [i, i + 1]
break
def sq(x, y):
return int((x_co[x + 1] - x_co[x]) * (y_co[y + 1] - y_co[y]))
# 探索
Q = []
# houmon = [[False] * yL for _ in range(xL)]
houmon = np.zeros((xL, yL))
ans = 0
is_inf = False
for x in xf:
for y in yf:
houmon[x][y] = 1
Q.append((x, y))
while Q:
x, y = Q.pop()
if x in [0, xL - 1] or y in [0, yL - 1]:
is_inf = True
break
ans += sq(x, y)
if (not houmon[x - 1][y]) and (not s_ex_yoko[x][y]):
houmon[x - 1][y] = True
Q.append((x - 1, y))
if (not houmon[x][y - 1]) and (not s_ex_tate[y][x]):
houmon[x][y - 1] = True
Q.append((x, y - 1))
if (not houmon[x + 1][y]) and (not s_ex_yoko[x + 1][y]):
houmon[x + 1][y] = True
Q.append((x + 1, y))
if (not houmon[x][y + 1]) and (not s_ex_tate[y + 1][x]):
houmon[x][y + 1] = True
Q.append((x, y + 1))
if is_inf:
print("INF")
else:
print(ans)
| Statement
Given is a positive integer N.
We will choose an integer K between 2 and N (inclusive), then we will repeat
the operation below until N becomes less than K.
* Operation: if K divides N, replace N with N/K; otherwise, replace N with N-K.
In how many choices of K will N become 1 in the end? | [{"input": "6", "output": "3\n \n\nThere are three choices of K in which N becomes 1 in the end: 2, 5, and 6.\n\nIn each of these choices, N will change as follows:\n\n * When K=2: 6 \\to 3 \\to 1\n * When K=5: 6 \\to 1\n * When K=6: 6 \\to 1\n\n* * *"}, {"input": "3141", "output": "13\n \n\n* * *"}, {"input": "314159265358", "output": "9"}] |
Print the number of choices of K in which N becomes 1 in the end.
* * * | s508268789 | Accepted | p02722 | Input is given from Standard Input in the following format:
N | def gcd(a, b):
while b:
a, b = b, a % b
return a
def isPrimeMR(n):
d = n - 1
d = d // (d & -d)
L = (
[2, 7, 61]
if n < 1 << 32
else (
[2, 3, 5, 7, 11, 13, 17]
if n < 1 << 48
else [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37]
)
)
for a in L:
t = d
y = pow(a, t, n)
if y == 1:
continue
while y != n - 1:
y = y * y % n
if y == 1 or t == n - 1:
return 0
t <<= 1
return 1
def findFactorRho(n):
m = 1 << n.bit_length() // 8
for c in range(1, 99):
f = lambda x: (x * x + c) % n
y, r, q, g = 2, 1, 1, 1
while g == 1:
x = y
for i in range(r):
y = f(y)
k = 0
while k < r and g == 1:
ys = y
for i in range(min(m, r - k)):
y = f(y)
q = q * abs(x - y) % n
g = gcd(q, n)
k += m
r <<= 1
if g == n:
g = 1
while g == 1:
ys = f(ys)
g = gcd(abs(x - ys), n)
if g < n:
if isPrimeMR(g):
return g
elif isPrimeMR(n // g):
return n // g
return findFactorRho(g)
def primeFactor(n):
i = 2
ret = {}
rhoFlg = 0
while i * i <= n:
k = 0
while n % i == 0:
n //= i
k += 1
if k:
ret[i] = k
i += i % 2 + (3 if i % 3 == 1 else 1)
if i == 101 and n >= 2**20:
while n > 1:
if isPrimeMR(n):
ret[n], n = 1, 1
else:
rhoFlg = 1
j = findFactorRho(n)
k = 0
while n % j == 0:
n //= j
k += 1
ret[j] = k
if n > 1:
ret[n] = 1
if rhoFlg:
ret = {x: ret[x] for x in sorted(ret)}
return ret
def divisors(N):
pf = primeFactor(N)
ret = [1]
for p in pf:
ret_prev = ret
ret = []
for i in range(pf[p] + 1):
for r in ret_prev:
ret.append(r * (p**i))
return sorted(ret)
def calc(n, k):
if n % k == 0:
return n // k
return n % k
def chk(n, k):
while n >= k:
n = calc(n, k)
return 1 if n == 1 else 0
N = int(input())
L = list(set(divisors(N) + divisors(N - 1)))
print(len([l for l in L if l > 1 and chk(N, l)]))
| Statement
Given is a positive integer N.
We will choose an integer K between 2 and N (inclusive), then we will repeat
the operation below until N becomes less than K.
* Operation: if K divides N, replace N with N/K; otherwise, replace N with N-K.
In how many choices of K will N become 1 in the end? | [{"input": "6", "output": "3\n \n\nThere are three choices of K in which N becomes 1 in the end: 2, 5, and 6.\n\nIn each of these choices, N will change as follows:\n\n * When K=2: 6 \\to 3 \\to 1\n * When K=5: 6 \\to 1\n * When K=6: 6 \\to 1\n\n* * *"}, {"input": "3141", "output": "13\n \n\n* * *"}, {"input": "314159265358", "output": "9"}] |
Print the number of choices of K in which N becomes 1 in the end.
* * * | s481248191 | Accepted | p02722 | Input is given from Standard Input in the following format:
N | from collections import defaultdict
roots = defaultdict(list)
for k in range(2, 10**6 + 1):
ki = k * k
while ki <= 10**12:
roots[ki].append(k)
ki *= k
def factors(n):
fhead = []
ftail = []
for x in range(1, int(n**0.5) + 1):
if n % x == 0:
fhead.append(x)
if x * x != n:
ftail.append(n // x)
return fhead + ftail[::-1]
def solve(N):
works = set()
# Answer seems to be anything of the form: N = (K ** i) * (j * K + 1)
# Try every divisor of N as K ** i
for d in factors(N):
# If i == 1, then K == d
k = d
if (N // d) % k == 1:
assert k <= N
works.add(k)
if d == 1:
# If i == 0, then K ** 0 == 1, so K = (N - 1) // j, so anything that is a factor of N - 1 works
works.update(factors(N - 1))
elif d in roots:
# For i >= 2, see if it's in the list of precomputed roots
for k in roots[d]:
if k > N:
break
if (N // d) % k == 1:
works.add(k)
works.discard(1)
return len(works)
(N,) = [int(x) for x in input().split()]
print(solve(N))
if False:
def brute(N, K):
while N >= K:
if N % K == 0:
N = N // K
else:
N = N - K
return N
for N in range(2, 10000):
count = 0
for K in range(2, N + 1):
temp = brute(N, K)
if temp == 1:
print(N, K, temp)
count += 1
print("##########", N, count, solve(N))
assert count == solve(N)
| Statement
Given is a positive integer N.
We will choose an integer K between 2 and N (inclusive), then we will repeat
the operation below until N becomes less than K.
* Operation: if K divides N, replace N with N/K; otherwise, replace N with N-K.
In how many choices of K will N become 1 in the end? | [{"input": "6", "output": "3\n \n\nThere are three choices of K in which N becomes 1 in the end: 2, 5, and 6.\n\nIn each of these choices, N will change as follows:\n\n * When K=2: 6 \\to 3 \\to 1\n * When K=5: 6 \\to 1\n * When K=6: 6 \\to 1\n\n* * *"}, {"input": "3141", "output": "13\n \n\n* * *"}, {"input": "314159265358", "output": "9"}] |
Print the number of choices of K in which N becomes 1 in the end.
* * * | s983245142 | Wrong Answer | p02722 | Input is given from Standard Input in the following format:
N | import sys
input_methods = ["clipboard", "file", "key"]
using_method = 0
input_method = input_methods[using_method]
tin = lambda: map(int, input().split())
lin = lambda: list(tin())
mod = 1000000007
# +++++
def ccc(v, k):
while v > k:
if v % k == 0:
v = v // k
else:
v = v % k
return v
def main():
s = int(input())
# b , c = tin()
# s = input()
if s == 2:
return 1
elif s == 3:
return 2
ret = 2
for i in range(2, s - 1):
if i * i > s:
break
if s % i == 1:
ret += 1 if i * i == s - 1 else 2
if s % i == 0:
if ccc(s, i) == 1:
ret += 1
oi = s // i
if oi != i and ccc(s, oi) == 1:
ret += 1
print(ret)
# +++++
isTest = False
def pa(v):
if isTest:
print(v)
def input_clipboard():
import clipboard
input_text = clipboard.get()
input_l = input_text.splitlines()
for l in input_l:
yield l
if __name__ == "__main__":
if sys.platform == "ios":
if input_method == input_methods[0]:
ic = input_clipboard()
input = lambda: ic.__next__()
elif input_method == input_methods[1]:
sys.stdin = open("inputFile.txt")
else:
pass
isTest = True
else:
pass
# input = sys.stdin.readline
ret = main()
if ret is not None:
print(ret)
| Statement
Given is a positive integer N.
We will choose an integer K between 2 and N (inclusive), then we will repeat
the operation below until N becomes less than K.
* Operation: if K divides N, replace N with N/K; otherwise, replace N with N-K.
In how many choices of K will N become 1 in the end? | [{"input": "6", "output": "3\n \n\nThere are three choices of K in which N becomes 1 in the end: 2, 5, and 6.\n\nIn each of these choices, N will change as follows:\n\n * When K=2: 6 \\to 3 \\to 1\n * When K=5: 6 \\to 1\n * When K=6: 6 \\to 1\n\n* * *"}, {"input": "3141", "output": "13\n \n\n* * *"}, {"input": "314159265358", "output": "9"}] |
Print the number of choices of K in which N becomes 1 in the end.
* * * | s859810597 | Runtime Error | p02722 | Input is given from Standard Input in the following format:
N | class Tree:
def __init__(self, n, edge):
self.n = n
self.tree = [[] for _ in range(n)]
for e in edge:
self.tree[e[0] - 1].append(e[1] - 1)
self.tree[e[1] - 1].append(e[0] - 1)
def setroot(self, root):
self.root = root
self.parent = [None for _ in range(self.n)]
self.parent[root] = -1
self.depth = [None for _ in range(self.n)]
self.depth[root] = 0
self.order = []
self.order.append(root)
stack = [root]
while stack:
node = stack.pop()
for adj in self.tree[node]:
if self.parent[adj] is None:
self.parent[adj] = node
self.depth[adj] = self.depth[node] + 1
self.order.append(adj)
stack.append(adj)
def rerooting(self, func, merge, ti, ei):
dp = [ti for _ in range(self.n)]
lt = [ei for _ in range(self.n)]
rt = [ei for _ in range(self.n)]
inv = [ei for _ in range(self.n)]
self.setroot(0)
for node in self.order[::-1]:
tmp = ti
for adj in self.tree[node]:
if self.parent[adj] == node:
lt[adj] = tmp
tmp = func(tmp, dp[adj])
tmp = ti
for adj in self.tree[node][::-1]:
if self.parent[adj] == node:
rt[adj] = tmp
tmp = func(tmp, dp[adj])
dp[node] = tmp
for node in self.order:
if node == 0:
continue
merged = merge(lt[node], rt[node])
par = self.parent[node]
inv[node] = func(merged, inv[par])
dp[node] = func(dp[node], inv[node])
return dp
class Factorial:
def __init__(self, n, mod):
self.mod = mod
self.factorial = [0 for _ in range(n + 1)]
self.inv = [0 for _ in range(n + 1)]
self.factorial[0] = 1
self.inv[0] = 1
for i in range(n):
self.factorial[i + 1] = self.factorial[i] * (i + 1) % mod
self.inv[n] = pow(self.factorial[n], mod - 2, mod)
for i in range(n)[::-1]:
self.inv[i] = self.inv[i + 1] * (i + 1) % mod
def fact(self, m):
return self.factorial[m]
def invfact(self, m):
return self.inv[m]
import sys
input = sys.stdin.readline
MOD = 1000000007
N = int(input())
E = [tuple(map(int, input().split())) for _ in range(N - 1)]
T = Tree(N, E)
F = Factorial(N + 1, MOD)
def func(node, adj):
size = node[1] + adj[1]
count = (
node[0] * adj[0] * F.invfact(adj[1]) * F.fact(size - 1) * F.invfact(node[1] - 1)
)
count %= MOD
return count, size
def merge(lt, rt):
size = lt[1] + rt[1] - 1
count = (
lt[0] * rt[0] * F.invfact(lt[1] - 1) * F.invfact(rt[1] - 1) * F.fact(size - 1)
)
count %= MOD
return count, size
ti = (1, 1)
ei = (1, 0)
D = T.rerooting(func, merge, ti, ei)
res = []
for i in range(N):
res.append(D[i][0])
print("\n".join(map(str, res)))
| Statement
Given is a positive integer N.
We will choose an integer K between 2 and N (inclusive), then we will repeat
the operation below until N becomes less than K.
* Operation: if K divides N, replace N with N/K; otherwise, replace N with N-K.
In how many choices of K will N become 1 in the end? | [{"input": "6", "output": "3\n \n\nThere are three choices of K in which N becomes 1 in the end: 2, 5, and 6.\n\nIn each of these choices, N will change as follows:\n\n * When K=2: 6 \\to 3 \\to 1\n * When K=5: 6 \\to 1\n * When K=6: 6 \\to 1\n\n* * *"}, {"input": "3141", "output": "13\n \n\n* * *"}, {"input": "314159265358", "output": "9"}] |
Print the number of choices of K in which N becomes 1 in the end.
* * * | s170548406 | Wrong Answer | p02722 | Input is given from Standard Input in the following format:
N | n = int(input())
a = [int(i + 2) for i in range(n - 1)]
for i, ai in enumerate(a):
m = n
while m % ai == 0:
if m >= ai and m % ai == 0:
m = m / ai
if m % ai != 1:
a[i] = 0
b = set(a)
print(len(b) - 1)
| Statement
Given is a positive integer N.
We will choose an integer K between 2 and N (inclusive), then we will repeat
the operation below until N becomes less than K.
* Operation: if K divides N, replace N with N/K; otherwise, replace N with N-K.
In how many choices of K will N become 1 in the end? | [{"input": "6", "output": "3\n \n\nThere are three choices of K in which N becomes 1 in the end: 2, 5, and 6.\n\nIn each of these choices, N will change as follows:\n\n * When K=2: 6 \\to 3 \\to 1\n * When K=5: 6 \\to 1\n * When K=6: 6 \\to 1\n\n* * *"}, {"input": "3141", "output": "13\n \n\n* * *"}, {"input": "314159265358", "output": "9"}] |
Print the number of choices of K in which N becomes 1 in the end.
* * * | s204466999 | Accepted | p02722 | Input is given from Standard Input in the following format:
N | # -*- coding: utf-8 -*-
"""
20
"""
N = int(input())
class Prime(object):
@staticmethod
def is_prime(n: int) -> bool:
"""
素数判定
>>> p = Prime()
>>> p.is_prime(2)
True
>>> p.is_prime(43)
True
>>> p.is_prime(4)
False
"""
if n == 1:
return False
if n == 2:
return True
for i in range(2, n):
if n % i == 0:
return False
if i * i > n:
return True
@staticmethod
def divisor(n: int, sort: bool = False) -> list:
"""
約数列挙
>>> p = Prime()
>>> p.divisor(6)
[1, 2, 3, 6]
"""
res = []
if n == 1:
return [1]
for i in range(1, n):
if n % i == 0:
res.append(i)
if i != n / i:
res.append(int(n / i))
if (i + 1) * (i + 1) > n:
if sort:
res.sort()
return res
# N-1の約数:1以外が全て当てはまる
temp1 = Prime.divisor(N - 1, sort=False)
# print(temp1)
cnt1 = len(temp1) - 1
# Nの約数K:Kで割り切った後でN % K == 1かどうかを見る
temp2 = Prime.divisor(N, sort=True)[1:]
# print(temp2)
cnt2 = 0
for temp in temp2:
a = N
while a % temp == 0:
a = a / temp
if a % temp == 1:
cnt2 += 1
print(cnt1 + cnt2)
| Statement
Given is a positive integer N.
We will choose an integer K between 2 and N (inclusive), then we will repeat
the operation below until N becomes less than K.
* Operation: if K divides N, replace N with N/K; otherwise, replace N with N-K.
In how many choices of K will N become 1 in the end? | [{"input": "6", "output": "3\n \n\nThere are three choices of K in which N becomes 1 in the end: 2, 5, and 6.\n\nIn each of these choices, N will change as follows:\n\n * When K=2: 6 \\to 3 \\to 1\n * When K=5: 6 \\to 1\n * When K=6: 6 \\to 1\n\n* * *"}, {"input": "3141", "output": "13\n \n\n* * *"}, {"input": "314159265358", "output": "9"}] |
Print the number of choices of K in which N becomes 1 in the end.
* * * | s442185391 | Wrong Answer | p02722 | Input is given from Standard Input in the following format:
N | N = int(input())
import math
lists = []
listT = []
t = 2
T = 0
n = N - 1
p = 1
while t <= math.sqrt(N):
if n % t == 0:
T = T + 1
n = n // t
p = p * t
lists.append(t)
if n == 1:
listT.append(T)
break
else:
t = t + 1
if T != 0:
listT.append(T)
T = 0
if p == 1:
lists.append(1)
lists.append(N)
listT = [1]
elif n != 1:
lists.append(n)
listT.append(1)
def prod(lista):
p = 1
for i in range(10000):
try:
p = p * (lista[i] + 1)
except IndexError:
return p - 1
A = prod(listT) + 2
print(A)
| Statement
Given is a positive integer N.
We will choose an integer K between 2 and N (inclusive), then we will repeat
the operation below until N becomes less than K.
* Operation: if K divides N, replace N with N/K; otherwise, replace N with N-K.
In how many choices of K will N become 1 in the end? | [{"input": "6", "output": "3\n \n\nThere are three choices of K in which N becomes 1 in the end: 2, 5, and 6.\n\nIn each of these choices, N will change as follows:\n\n * When K=2: 6 \\to 3 \\to 1\n * When K=5: 6 \\to 1\n * When K=6: 6 \\to 1\n\n* * *"}, {"input": "3141", "output": "13\n \n\n* * *"}, {"input": "314159265358", "output": "9"}] |
Print the number of the positive divisors of N!, modulo 10^9+7.
* * * | s358807264 | Accepted | p03830 | The input is given from Standard Input in the following format:
N | N = int(input())
mod = pow(10, 9) + 7
S = []
A = [True] * (N + 1)
A[0] = A[1] = False
for i in range(2, N + 1):
if A[i]:
S.append(i)
A[i::i] = [False] * (N // i)
B = [1] * (N + 1)
for i in range(2, N + 1):
n = i
for s in S:
while n % s == 0:
B[s] += 1
n //= s
ans = 1
for b in B:
ans *= b
print(ans % mod)
| Statement
You are given an integer N. Find the number of the positive divisors of N!,
modulo 10^9+7. | [{"input": "3", "output": "4\n \n\nThere are four divisors of 3! =6: 1, 2, 3 and 6. Thus, the output should be 4.\n\n* * *"}, {"input": "6", "output": "30\n \n\n* * *"}, {"input": "1000", "output": "972926972"}] |
Print the number of the positive divisors of N!, modulo 10^9+7.
* * * | s919015438 | Accepted | p03830 | The input is given from Standard Input in the following format:
N | import sys
input = sys.stdin.readline
def main():
N = int(input())
MOD = int(1e9) + 7
if N == 1:
print(1)
exit()
primes = [
2,
3,
5,
7,
11,
13,
17,
19,
23,
29,
31,
37,
41,
43,
47,
53,
59,
61,
67,
71,
73,
79,
83,
89,
97,
101,
103,
107,
109,
113,
127,
131,
137,
139,
149,
151,
157,
163,
167,
173,
179,
181,
191,
193,
197,
199,
211,
223,
227,
229,
233,
239,
241,
251,
257,
263,
269,
271,
277,
281,
283,
293,
307,
311,
313,
317,
331,
337,
347,
349,
353,
359,
367,
373,
379,
383,
389,
397,
401,
409,
419,
421,
431,
433,
439,
443,
449,
457,
461,
463,
467,
479,
487,
491,
499,
503,
509,
521,
523,
541,
547,
557,
563,
569,
571,
577,
587,
593,
599,
601,
607,
613,
617,
619,
631,
641,
643,
647,
653,
659,
661,
673,
677,
683,
691,
701,
709,
719,
727,
733,
739,
743,
751,
757,
761,
769,
773,
787,
797,
809,
811,
821,
823,
827,
829,
839,
853,
857,
859,
863,
877,
881,
883,
887,
907,
911,
919,
929,
937,
941,
947,
953,
967,
971,
977,
983,
991,
997,
]
count = [0] * len(primes)
for i in range(2, N + 1):
for j in range(len(primes)):
while i % primes[j] == 0:
count[j] += 1
i //= primes[j]
# print(count)
ans = 1
for i in range(len(count)):
if count[i] > 0:
ans *= count[i] + 1
ans %= MOD
print(ans)
if __name__ == "__main__":
main()
| Statement
You are given an integer N. Find the number of the positive divisors of N!,
modulo 10^9+7. | [{"input": "3", "output": "4\n \n\nThere are four divisors of 3! =6: 1, 2, 3 and 6. Thus, the output should be 4.\n\n* * *"}, {"input": "6", "output": "30\n \n\n* * *"}, {"input": "1000", "output": "972926972"}] |
Print the number of the positive divisors of N!, modulo 10^9+7.
* * * | s916668053 | Accepted | p03830 | The input is given from Standard Input in the following format:
N | #!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI():
return [int(x) for x in sys.stdin.readline().split()]
def I():
return int(sys.stdin.readline())
def LS():
return [list(x) for x in sys.stdin.readline().split()]
def S():
return list(sys.stdin.readline())[:-1]
def IR(n):
return [I() for i in range(n)]
def LIR(n):
return [LI() for i in range(n)]
def SR(n):
return [S() for i in range(n)]
def LSR(n):
return [LS() for i in range(n)]
sys.setrecursionlimit(1000000)
mod = 1000000007
# A
def A():
n = I()
return
# B
def B():
n = I()
return
# C
def C():
def factor(n):
if n < 4:
return {1: 1, n: 1}
else:
d = defaultdict(lambda: 0)
i = 2
m = n
while i**2 <= n:
if m % i == 0:
while m % i == 0:
d[i] += 1
m //= i
i += 1
d[m] += 1
return d
n = I()
if n == 1:
print(1)
quit()
f = defaultdict(lambda: 0)
for i in range(2, n + 1):
fact = factor(i)
for j, k in fact.items():
if j > 1:
f[j] += k
f[j] %= mod
ans = 1
for i in f.values():
ans *= i + 1
ans %= mod
print(ans)
return
# D
def D():
def root(x):
if x == par[x]:
return x
par[x] = root(par[x])
return par[x]
def unite(x, y):
x = root(x)
y = root(y)
if rank[x] < rank[y]:
par[x] = y
else:
par[y] = x
if rank[x] == rank[y]:
rank[x] += 1
n, a, b = LI()
par = [i for i in range(n)]
rank = [0] * n
x = LI()
for i in range(n - 1):
if a * (x[i + 1] - x[i]) < b:
unite(i, i + 1)
ans = 0
f = [1] * n
f[0] = 0
for i in range(1, n):
if f[root(i)]:
ans += b
f[root(i)] = 0
else:
ans += a * (x[i] - x[i - 1])
print(ans)
return
# E
def E():
n = I()
return
# F
def F():
n = I()
return
# Solve
if __name__ == "__main__":
C()
| Statement
You are given an integer N. Find the number of the positive divisors of N!,
modulo 10^9+7. | [{"input": "3", "output": "4\n \n\nThere are four divisors of 3! =6: 1, 2, 3 and 6. Thus, the output should be 4.\n\n* * *"}, {"input": "6", "output": "30\n \n\n* * *"}, {"input": "1000", "output": "972926972"}] |
Print the number of the positive divisors of N!, modulo 10^9+7.
* * * | s267777264 | Runtime Error | p03830 | The input is given from Standard Input in the following format:
N | from math import floor
N, A, B, C, D = map(int, input().split())
mod = 10**9 + 7
factorials = [None for i in range(N + 1)]
factorials[0] = 1
for i in range(1, N + 1):
factorials[i] = (factorials[i - 1] * i) % mod
def inv(x):
ret = 1
k = mod - 2
y = x
while k:
if k & 1:
ret = (ret * y) % mod
y = (y * y) % mod
k //= 2
return ret
finv = [0] * (N + 1)
finv[N] = inv(factorials[N])
for i in range(N, 0, -1):
finv[i - 1] = (finv[i] * i) % mod
def calc(i, j, k):
tmp = finv[N - j]
tmp = (tmp * finv[k]) % mod
tmp = (tmp * factorials[N - j + i * k]) % mod
y = finv[i]
ret = 1
while k:
if k & 1:
ret = (ret * y) % mod
y = (y * y) % mod
k //= 2
return (ret * tmp) % mod
dp = [[0] * (N + 1) for _ in range(N + 1)]
for i in range(B + 1):
dp[i][0] = 1
ls = [0] + list(range(C, D + 1))
l = len(ls)
for i in range(A, B + 1):
for j in range(1, N + 1):
tmp = 0
for k in ls:
if k > j / i:
break
tmp = (tmp + dp[i - 1][j - i * k] * calc(i, j, k)) % mod
dp[i][j] = tmp
print(dp[B][N])
| Statement
You are given an integer N. Find the number of the positive divisors of N!,
modulo 10^9+7. | [{"input": "3", "output": "4\n \n\nThere are four divisors of 3! =6: 1, 2, 3 and 6. Thus, the output should be 4.\n\n* * *"}, {"input": "6", "output": "30\n \n\n* * *"}, {"input": "1000", "output": "972926972"}] |
Print the number of the positive divisors of N!, modulo 10^9+7.
* * * | s221429189 | Wrong Answer | p03830 | The input is given from Standard Input in the following format:
N | import sys
import math
import copy
import heapq
from functools import cmp_to_key
from bisect import bisect_left, bisect_right
from collections import defaultdict, deque, Counter
sys.setrecursionlimit(1000000)
# input aliases
input = sys.stdin.readline
getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]
INF = float("inf")
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD - 2, MOD)
def nck(n, k, kaijyo):
return (npk(n, k, kaijyo) * divide(kaijyo[k])) % MOD
def npk(n, k, kaijyo):
if k == 0 or k == n:
return n % MOD
return (kaijyo[n] * divide(kaijyo[n - k])) % MOD
def fact_and_inv(SIZE):
inv = [0] * SIZE # inv[j] = j^{-1} mod MOD
fac = [0] * SIZE # fac[j] = j! mod MOD
finv = [0] * SIZE # finv[j] = (j!)^{-1} mod MOD
inv[1] = 1
fac[0] = fac[1] = 1
finv[0] = finv[1] = 1
for i in range(2, SIZE):
inv[i] = MOD - (MOD // i) * inv[MOD % i] % MOD
fac[i] = fac[i - 1] * i % MOD
finv[i] = finv[i - 1] * inv[i] % MOD
return fac, finv
def renritsu(A, Y):
# example 2x + y = 3, x + 3y = 4
# A = [[2,1], [1,3]])
# Y = [[3],[4]] または [3,4]
A = np.matrix(A)
Y = np.matrix(Y)
Y = np.reshape(Y, (-1, 1))
X = np.linalg.solve(A, Y)
# [1.0, 1.0]
return X.flatten().tolist()[0]
class TwoDimGrid:
# 2次元座標 -> 1次元
def __init__(self, h, w, wall="#"):
self.h = h
self.w = w
self.size = (h + 2) * (w + 2)
self.wall = wall
self.get_grid()
# self.init_cost()
def get_grid(self):
grid = [self.wall * (self.w + 2)]
for i in range(self.h):
grid.append(self.wall + getS() + self.wall)
grid.append(self.wall * (self.w + 2))
self.grid = grid
def init_cost(self):
self.cost = [INF] * self.size
def pos(self, x, y):
# 壁も含めて0-indexed 元々の座標だけ考えると1-indexed
return y * (self.w + 2) + x
def getgrid(self, x, y):
return self.grid[y][x]
def get(self, x, y):
return self.cost[self.pos(x, y)]
def set(self, x, y, v):
self.cost[self.pos(x, y)] = v
return
def show(self):
for i in range(self.h + 2):
print(self.cost[(self.w + 2) * i : (self.w + 2) * (i + 1)])
def showsome(self, tgt):
for t in tgt:
print(t)
return
def showsomejoin(self, tgt):
for t in tgt:
print("".join(t))
return
def search(self):
grid = self.grid
move = [(0, 1), (0, -1), (1, 0), (-1, 0)]
move_eight = [
(0, 1),
(0, -1),
(1, 0),
(-1, 0),
(1, 1),
(1, -1),
(-1, 1),
(-1, -1),
]
# for i in range(1, self.h+1):
# for j in range(1, self.w+1):
# cx, cy = j, i
# for dx, dy in move_eight:
# nx, ny = dx + cx, dy + cy
def soinsu(n):
ret = defaultdict(int)
for i in range(2, int(math.sqrt(n) + 2)):
if n % i == 0:
while True:
if n % i == 0:
ret[i] += 1
n //= i
else:
break
if not ret:
return {n: 1}
return ret
def solve():
n = getN()
p = defaultdict(int)
for i in range(2, n + 1):
so = soinsu(i)
for k, v in so.items():
p[k] += v
ans = 1
# print(p)
for v in p.values():
ans *= v + 1
ans %= MOD
print(ans)
return
def main():
n = getN()
for _ in range(n):
solve()
return
if __name__ == "__main__":
# main()
solve()
| Statement
You are given an integer N. Find the number of the positive divisors of N!,
modulo 10^9+7. | [{"input": "3", "output": "4\n \n\nThere are four divisors of 3! =6: 1, 2, 3 and 6. Thus, the output should be 4.\n\n* * *"}, {"input": "6", "output": "30\n \n\n* * *"}, {"input": "1000", "output": "972926972"}] |
Print the number of the positive divisors of N!, modulo 10^9+7.
* * * | s130159629 | Accepted | p03830 | The input is given from Standard Input in the following format:
N | # prime_number?
n = int(input())
from math import sqrt
from random import randint
def isprime(num): # O(sqrt(n))
root = int(sqrt(n))
for i in range(2, root + 1):
if num % i == 0:
return False
return True
def isprime_(num, n=1): # O(k+n)未満 (ミラー・ラビンテスト)
q = num
if q == 2:
return True
if q == 1 or q & 1 == 0:
return False
d = (q - 1) >> 1
while d & 1 == 0:
d >>= 1
for i in range(n):
a = randint(1, q - 1)
t = d
y = pow(a, t, q)
while t != q - 1 and y != 1 and y != q - 1:
y = pow(y, 2, q)
t <<= 1
if y != q - 1 and t & 1 == 0:
return False
return True
def dividers(num, sort=True):
root = int(sqrt(n))
l = []
m = []
for i in range(1, root + 1):
if num % i == 0:
l.append(i)
if i < root:
m.append(int(num / i))
if sort:
l.extend(sorted(m))
return l
else:
l.extend(m)
return l
def decomposit(num):
root = int(sqrt(n))
l = []
i = 2
while i < root + 1:
if num % i == 0:
j = 0
while num % i == 0:
j += 1
num = num / i
l.append([i, j])
root = int(sqrt(n))
i += 1
if num != 1:
l.append([int(num), 1])
return l
l = {}
for i in range(n + 1):
if isprime_(i):
l[i] = 0
for i in range(1, n + 1):
for j in decomposit(i):
l[j[0]] += j[1]
d = 1
for i in l.values():
d *= i + 1
d %= 10**9 + 7
print(d)
| Statement
You are given an integer N. Find the number of the positive divisors of N!,
modulo 10^9+7. | [{"input": "3", "output": "4\n \n\nThere are four divisors of 3! =6: 1, 2, 3 and 6. Thus, the output should be 4.\n\n* * *"}, {"input": "6", "output": "30\n \n\n* * *"}, {"input": "1000", "output": "972926972"}] |
Print the number of the positive divisors of N!, modulo 10^9+7.
* * * | s132939662 | Wrong Answer | p03830 | The input is given from Standard Input in the following format:
N | from collections import Counter
def kaijou(value):
sum_ = 1
keep = []
for v in range(1, value + 1):
keep.append(count_element(v))
# tmp = {}
# for di in keep:
# dict(tmp, di)
tmp = {}
for di in keep:
# print (di)
tmp = Counter(tmp) + Counter(di)
want = 1
for i in tmp.values():
want *= i + 1
return int(want % 1000000007)
# return tmp
def count_element(value):
max_value = value
if value == 0:
return {}
min_value = 1
element_count = 1
hash_ = {}
while max_value != 1:
for v in range(min_value + 1, max_value + 1):
count = 0
while max_value % v == 0:
max_value = int(max_value / v)
count += 1
if count == 0:
continue
element_count *= count
# print (element_count)
min_value = v
hash_[v] = element_count
break
return hash_
if __name__ == "__main__":
print(kaijou(int(input())))
| Statement
You are given an integer N. Find the number of the positive divisors of N!,
modulo 10^9+7. | [{"input": "3", "output": "4\n \n\nThere are four divisors of 3! =6: 1, 2, 3 and 6. Thus, the output should be 4.\n\n* * *"}, {"input": "6", "output": "30\n \n\n* * *"}, {"input": "1000", "output": "972926972"}] |
Print the number of the positive divisors of N!, modulo 10^9+7.
* * * | s933304383 | Runtime Error | p03830 | The input is given from Standard Input in the following format:
N | #include <bits/stdc++.h>
#include <stdlib.h>
#include <string>
#include <algorithm>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> P;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
int N;
int prime[1001];//i番目の素数の数
ll MOD = 1000000007;
int factorization(int n){
int i = 2;
int temp = n;
while (i*i <= n){
while (temp % i == 0){
prime[i]++;
temp /= i;
}
i++;
}
if (temp != 1){
prime[temp]++;
}
}
int main(){
cin >> N;
rep(i, N+1) prime[i] = 0;
rep(i, N) factorization(i + 1);
ll ans = 1;
rep(i, N+1){
if (prime[i] != 0){
ans *= (prime[i] +1);
ans %= MOD;
}
}
cout << ans << endl;
} | Statement
You are given an integer N. Find the number of the positive divisors of N!,
modulo 10^9+7. | [{"input": "3", "output": "4\n \n\nThere are four divisors of 3! =6: 1, 2, 3 and 6. Thus, the output should be 4.\n\n* * *"}, {"input": "6", "output": "30\n \n\n* * *"}, {"input": "1000", "output": "972926972"}] |
Print the number of the positive divisors of N!, modulo 10^9+7.
* * * | s564821559 | Runtime Error | p03830 | The input is given from Standard Input in the following format:
N | import math
def make_divisors(n):
divisors = []
for i in range(1, int(n**0.5)+1):
if n % i == 0:
divisors.append(i)
if i != n // i:
divisors.append(n//i)
# divisors.sort()
return divisors
n = int(input())
print(len(make_divisors(math.factorial(n)L))%(10**9+7))
| Statement
You are given an integer N. Find the number of the positive divisors of N!,
modulo 10^9+7. | [{"input": "3", "output": "4\n \n\nThere are four divisors of 3! =6: 1, 2, 3 and 6. Thus, the output should be 4.\n\n* * *"}, {"input": "6", "output": "30\n \n\n* * *"}, {"input": "1000", "output": "972926972"}] |
Print the number of the positive divisors of N!, modulo 10^9+7.
* * * | s024400702 | Runtime Error | p03830 | The input is given from Standard Input in the following format:
N | x
| Statement
You are given an integer N. Find the number of the positive divisors of N!,
modulo 10^9+7. | [{"input": "3", "output": "4\n \n\nThere are four divisors of 3! =6: 1, 2, 3 and 6. Thus, the output should be 4.\n\n* * *"}, {"input": "6", "output": "30\n \n\n* * *"}, {"input": "1000", "output": "972926972"}] |
Print the number of the positive divisors of N!, modulo 10^9+7.
* * * | s427741539 | Wrong Answer | p03830 | The input is given from Standard Input in the following format:
N | N = int(input())
print(2 ** (N - 1))
| Statement
You are given an integer N. Find the number of the positive divisors of N!,
modulo 10^9+7. | [{"input": "3", "output": "4\n \n\nThere are four divisors of 3! =6: 1, 2, 3 and 6. Thus, the output should be 4.\n\n* * *"}, {"input": "6", "output": "30\n \n\n* * *"}, {"input": "1000", "output": "972926972"}] |
Print the maximum sum of values of jewels that Snuke the thief can steal.
* * * | s984077436 | Wrong Answer | p03099 | Input is given from Standard Input in the following format:
N
x_1 y_1 v_1
x_2 y_2 v_2
:
x_N y_N v_N
M
t_1 a_1 b_1
t_2 a_2 b_2
:
t_M a_M b_M | import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**9)
from bisect import bisect_left, bisect_right
class MinCostFlow:
def __init__(self, n):
self.n = n
self.edges = [[] for i in range(n)]
def add_edge(self, fr, to, cap, cost):
self.edges[fr].append([to, cap, cost, len(self.edges[to])])
self.edges[to].append([fr, 0, -cost, len(self.edges[fr]) - 1])
def MinCost(self, source, sink, flow):
inf = 10**15 + 1
n, E = self.n, self.edges
prev_v, prev_e = [0] * n, [0] * n
mincost = 0
while flow:
dist = [inf] * n
dist[source] = 0
flag = True
while flag:
flag = False
for v in range(n):
if dist[v] == inf:
continue
Ev = E[v]
for i in range(len(Ev)):
to, cap, cost, rev = Ev[i]
if cap > 0 and dist[v] + cost < dist[to]:
dist[to] = dist[v] + cost
prev_v[to], prev_e[to] = v, i
flag = True
if dist[sink] == inf:
return -1
f = flow
v = sink
while v != source:
f = min(f, E[prev_v[v]][prev_e[v]][1])
v = prev_v[v]
flow -= f
mincost += f * dist[sink]
v = sink
while v != source:
E[prev_v[v]][prev_e[v]][1] -= f
rev = E[prev_v[v]][prev_e[v]][3]
E[v][rev][1] += f
v = prev_v[v]
return mincost
n = int(input())
J = []
L_org, D_org = [1] * n, [1] * n
for _ in range(n):
x, y, v = map(int, input().split())
J.append((x, y, v))
m = int(input())
T = []
for _ in range(m):
t, a, b = input().split()
a, b = int(a), int(b)
T.append((t, a, b))
if t == "L":
L_org[b] = a + 1
elif t == "D":
D_org[b] = a + 1
for i in range(1, n):
L_org[i] = max(L_org[i - 1], L_org[i])
D_org[i] = max(D_org[i - 1], D_org[i])
def solve(k):
L, D = L_org[:k], D_org[:k]
R, U = [100] * k, [100] * k
for t, a, b in T:
if k - b - 1 >= 0:
if t == "R":
R[k - b - 1] = a - 1
elif t == "U":
U[k - b - 1] = a - 1
for i in range(k - 2, -1, -1):
R[i] = min(R[i], R[i + 1])
U[i] = min(U[i], U[i + 1])
solver = MinCostFlow(2 * n + 2 * k + 2)
for i in range(1, k + 1):
solver.add_edge(0, i, 1, 0)
solver.add_edge(2 * n + k + i, 2 * n + 2 * k + 1, 1, 0)
for i in range(n):
v = J[i][2]
solver.add_edge(k + i + 1, n + k + i + 1, 1, -v)
for i in range(n):
x, y = J[i][0], J[i][1]
l = bisect_right(L, x)
r = bisect_left(R, x) + 1
d = bisect_right(D, y)
u = bisect_left(U, y) + 1
for j in range(r, l + 1):
solver.add_edge(j, k + i + 1, 1, 0)
for j in range(u, d + 1):
solver.add_edge(n + k + i + 1, 2 * n + k + j, 1, 0)
return -solver.MinCost(0, 2 * n + 2 * k + 1, k)
ans = 0
k = 1
while True:
tmp = solve(k)
ans = max(ans, tmp)
if tmp == -1 or k == n:
break
k += 1
print(ans)
| Statement
A museum exhibits N jewels, Jewel 1, 2, ..., N. The coordinates of Jewel i are
(x_i, y_i) (the museum can be regarded as a two-dimensional plane), and the
value of that jewel is v_i.
Snuke the thief will steal some of these jewels.
There are M conditions, Condition 1, 2, ..., M, that must be met when stealing
jewels, or he will be caught by the detective. Each condition has one of the
following four forms:
* (t_i =`L`, a_i, b_i) : Snuke can only steal at most b_i jewels whose x coordinates are a_i or smaller.
* (t_i =`R`, a_i, b_i) : Snuke can only steal at most b_i jewels whose x coordinates are a_i or larger.
* (t_i =`D`, a_i, b_i) : Snuke can only steal at most b_i jewels whose y coordinates are a_i or smaller.
* (t_i =`U`, a_i, b_i) : Snuke can only steal at most b_i jewels whose y coordinates are a_i or larger.
Find the maximum sum of values of jewels that Snuke the thief can steal. | [{"input": "7\n 1 3 6\n 1 5 9\n 3 1 8\n 4 3 8\n 6 2 9\n 5 4 11\n 5 7 10\n 4\n L 3 1\n R 2 3\n D 5 3\n U 4 2", "output": "36\n \n\n\n\nStealing Jewel 1, 5, 6 and 7 results in the total value of 36.\n\n* * *"}, {"input": "3\n 1 2 3\n 4 5 6\n 7 8 9\n 1\n L 100 0", "output": "0\n \n\n* * *"}, {"input": "4\n 1 1 10\n 1 2 11\n 2 1 12\n 2 2 13\n 3\n L 8 3\n L 9 2\n L 10 1", "output": "13\n \n\n* * *"}, {"input": "10\n 66 47 71040136000\n 65 77 74799603000\n 80 53 91192869000\n 24 34 24931901000\n 91 78 49867703000\n 68 71 46108236000\n 46 73 74799603000\n 56 63 93122668000\n 32 51 71030136000\n 51 26 70912345000\n 21\n L 51 1\n L 7 0\n U 47 4\n R 92 0\n R 91 1\n D 53 2\n R 65 3\n D 13 0\n U 63 3\n L 68 3\n D 47 1\n L 91 5\n R 32 4\n L 66 2\n L 80 4\n D 77 4\n U 73 1\n D 78 5\n U 26 5\n R 80 2\n R 24 5", "output": "305223377000"}] |
Print the performance required to achieve the objective.
* * * | s010965433 | Accepted | p03563 | Input is given from Standard Input in the following format:
R
G | print((-1) * int(input()) + 2 * int(input()))
| Statement
Takahashi is a user of a site that hosts programming contests.
When a user competes in a contest, the _rating_ of the user (not necessarily
an integer) changes according to the _performance_ of the user, as follows:
* Let the current rating of the user be a.
* Suppose that the performance of the user in the contest is b.
* Then, the new rating of the user will be the avarage of a and b.
For example, if a user with rating 1 competes in a contest and gives
performance 1000, his/her new rating will be 500.5, the average of 1 and 1000.
Takahashi's current rating is R, and he wants his rating to be exactly G after
the next contest.
Find the performance required to achieve it. | [{"input": "2002\n 2017", "output": "2032\n \n\nTakahashi's current rating is 2002. \nIf his performance in the contest is 2032, his rating will be the average of\n2002 and 2032, which is equal to the desired rating, 2017.\n\n* * *"}, {"input": "4500\n 0", "output": "-4500\n \n\nAlthough the current and desired ratings are between 0 and 4500, the\nperformance of a user can be below 0."}] |
Print the performance required to achieve the objective.
* * * | s725761971 | Runtime Error | p03563 | Input is given from Standard Input in the following format:
R
G | r, a = map(int, input().split())
print(2 * a - r)
| Statement
Takahashi is a user of a site that hosts programming contests.
When a user competes in a contest, the _rating_ of the user (not necessarily
an integer) changes according to the _performance_ of the user, as follows:
* Let the current rating of the user be a.
* Suppose that the performance of the user in the contest is b.
* Then, the new rating of the user will be the avarage of a and b.
For example, if a user with rating 1 competes in a contest and gives
performance 1000, his/her new rating will be 500.5, the average of 1 and 1000.
Takahashi's current rating is R, and he wants his rating to be exactly G after
the next contest.
Find the performance required to achieve it. | [{"input": "2002\n 2017", "output": "2032\n \n\nTakahashi's current rating is 2002. \nIf his performance in the contest is 2032, his rating will be the average of\n2002 and 2032, which is equal to the desired rating, 2017.\n\n* * *"}, {"input": "4500\n 0", "output": "-4500\n \n\nAlthough the current and desired ratings are between 0 and 4500, the\nperformance of a user can be below 0."}] |
Print the performance required to achieve the objective.
* * * | s718577459 | Runtime Error | p03563 | Input is given from Standard Input in the following format:
R
G | print(eval(("2*" +input()).replace(" ","-")) | Statement
Takahashi is a user of a site that hosts programming contests.
When a user competes in a contest, the _rating_ of the user (not necessarily
an integer) changes according to the _performance_ of the user, as follows:
* Let the current rating of the user be a.
* Suppose that the performance of the user in the contest is b.
* Then, the new rating of the user will be the avarage of a and b.
For example, if a user with rating 1 competes in a contest and gives
performance 1000, his/her new rating will be 500.5, the average of 1 and 1000.
Takahashi's current rating is R, and he wants his rating to be exactly G after
the next contest.
Find the performance required to achieve it. | [{"input": "2002\n 2017", "output": "2032\n \n\nTakahashi's current rating is 2002. \nIf his performance in the contest is 2032, his rating will be the average of\n2002 and 2032, which is equal to the desired rating, 2017.\n\n* * *"}, {"input": "4500\n 0", "output": "-4500\n \n\nAlthough the current and desired ratings are between 0 and 4500, the\nperformance of a user can be below 0."}] |
Print the performance required to achieve the objective.
* * * | s914321364 | Runtime Error | p03563 | Input is given from Standard Input in the following format:
R
G | print(-input() + input() * 2)
| Statement
Takahashi is a user of a site that hosts programming contests.
When a user competes in a contest, the _rating_ of the user (not necessarily
an integer) changes according to the _performance_ of the user, as follows:
* Let the current rating of the user be a.
* Suppose that the performance of the user in the contest is b.
* Then, the new rating of the user will be the avarage of a and b.
For example, if a user with rating 1 competes in a contest and gives
performance 1000, his/her new rating will be 500.5, the average of 1 and 1000.
Takahashi's current rating is R, and he wants his rating to be exactly G after
the next contest.
Find the performance required to achieve it. | [{"input": "2002\n 2017", "output": "2032\n \n\nTakahashi's current rating is 2002. \nIf his performance in the contest is 2032, his rating will be the average of\n2002 and 2032, which is equal to the desired rating, 2017.\n\n* * *"}, {"input": "4500\n 0", "output": "-4500\n \n\nAlthough the current and desired ratings are between 0 and 4500, the\nperformance of a user can be below 0."}] |
Print the performance required to achieve the objective.
* * * | s241809127 | Wrong Answer | p03563 | Input is given from Standard Input in the following format:
R
G | i, p = int, input
print(2 * (i(p()) - i(p())))
| Statement
Takahashi is a user of a site that hosts programming contests.
When a user competes in a contest, the _rating_ of the user (not necessarily
an integer) changes according to the _performance_ of the user, as follows:
* Let the current rating of the user be a.
* Suppose that the performance of the user in the contest is b.
* Then, the new rating of the user will be the avarage of a and b.
For example, if a user with rating 1 competes in a contest and gives
performance 1000, his/her new rating will be 500.5, the average of 1 and 1000.
Takahashi's current rating is R, and he wants his rating to be exactly G after
the next contest.
Find the performance required to achieve it. | [{"input": "2002\n 2017", "output": "2032\n \n\nTakahashi's current rating is 2002. \nIf his performance in the contest is 2032, his rating will be the average of\n2002 and 2032, which is equal to the desired rating, 2017.\n\n* * *"}, {"input": "4500\n 0", "output": "-4500\n \n\nAlthough the current and desired ratings are between 0 and 4500, the\nperformance of a user can be below 0."}] |
Print the performance required to achieve the objective.
* * * | s435073607 | Runtime Error | p03563 | Input is given from Standard Input in the following format:
R
G | s = input()
print(chr(ord(s) + 1))
| Statement
Takahashi is a user of a site that hosts programming contests.
When a user competes in a contest, the _rating_ of the user (not necessarily
an integer) changes according to the _performance_ of the user, as follows:
* Let the current rating of the user be a.
* Suppose that the performance of the user in the contest is b.
* Then, the new rating of the user will be the avarage of a and b.
For example, if a user with rating 1 competes in a contest and gives
performance 1000, his/her new rating will be 500.5, the average of 1 and 1000.
Takahashi's current rating is R, and he wants his rating to be exactly G after
the next contest.
Find the performance required to achieve it. | [{"input": "2002\n 2017", "output": "2032\n \n\nTakahashi's current rating is 2002. \nIf his performance in the contest is 2032, his rating will be the average of\n2002 and 2032, which is equal to the desired rating, 2017.\n\n* * *"}, {"input": "4500\n 0", "output": "-4500\n \n\nAlthough the current and desired ratings are between 0 and 4500, the\nperformance of a user can be below 0."}] |
Print the performance required to achieve the objective.
* * * | s454909519 | Runtime Error | p03563 | Input is given from Standard Input in the following format:
R
G | https://atcoder.jp/contests/abc076/submissions/16272116 | Statement
Takahashi is a user of a site that hosts programming contests.
When a user competes in a contest, the _rating_ of the user (not necessarily
an integer) changes according to the _performance_ of the user, as follows:
* Let the current rating of the user be a.
* Suppose that the performance of the user in the contest is b.
* Then, the new rating of the user will be the avarage of a and b.
For example, if a user with rating 1 competes in a contest and gives
performance 1000, his/her new rating will be 500.5, the average of 1 and 1000.
Takahashi's current rating is R, and he wants his rating to be exactly G after
the next contest.
Find the performance required to achieve it. | [{"input": "2002\n 2017", "output": "2032\n \n\nTakahashi's current rating is 2002. \nIf his performance in the contest is 2032, his rating will be the average of\n2002 and 2032, which is equal to the desired rating, 2017.\n\n* * *"}, {"input": "4500\n 0", "output": "-4500\n \n\nAlthough the current and desired ratings are between 0 and 4500, the\nperformance of a user can be below 0."}] |
Print the performance required to achieve the objective.
* * * | s780458512 | Runtime Error | p03563 | Input is given from Standard Input in the following format:
R
G | a = int(input())
b = int(input())
print(2b - a) | Statement
Takahashi is a user of a site that hosts programming contests.
When a user competes in a contest, the _rating_ of the user (not necessarily
an integer) changes according to the _performance_ of the user, as follows:
* Let the current rating of the user be a.
* Suppose that the performance of the user in the contest is b.
* Then, the new rating of the user will be the avarage of a and b.
For example, if a user with rating 1 competes in a contest and gives
performance 1000, his/her new rating will be 500.5, the average of 1 and 1000.
Takahashi's current rating is R, and he wants his rating to be exactly G after
the next contest.
Find the performance required to achieve it. | [{"input": "2002\n 2017", "output": "2032\n \n\nTakahashi's current rating is 2002. \nIf his performance in the contest is 2032, his rating will be the average of\n2002 and 2032, which is equal to the desired rating, 2017.\n\n* * *"}, {"input": "4500\n 0", "output": "-4500\n \n\nAlthough the current and desired ratings are between 0 and 4500, the\nperformance of a user can be below 0."}] |
Print the performance required to achieve the objective.
* * * | s381191544 | Runtime Error | p03563 | Input is given from Standard Input in the following format:
R
G | a = int(input())
b = int(input())
print(2b - a) | Statement
Takahashi is a user of a site that hosts programming contests.
When a user competes in a contest, the _rating_ of the user (not necessarily
an integer) changes according to the _performance_ of the user, as follows:
* Let the current rating of the user be a.
* Suppose that the performance of the user in the contest is b.
* Then, the new rating of the user will be the avarage of a and b.
For example, if a user with rating 1 competes in a contest and gives
performance 1000, his/her new rating will be 500.5, the average of 1 and 1000.
Takahashi's current rating is R, and he wants his rating to be exactly G after
the next contest.
Find the performance required to achieve it. | [{"input": "2002\n 2017", "output": "2032\n \n\nTakahashi's current rating is 2002. \nIf his performance in the contest is 2032, his rating will be the average of\n2002 and 2032, which is equal to the desired rating, 2017.\n\n* * *"}, {"input": "4500\n 0", "output": "-4500\n \n\nAlthough the current and desired ratings are between 0 and 4500, the\nperformance of a user can be below 0."}] |
Print the performance required to achieve the objective.
* * * | s295074143 | Runtime Error | p03563 | Input is given from Standard Input in the following format:
R
G | c = input()
t = input()
lic = list(c)
lit = list(t)
ans = []
lia = []
n = len(c) - len(t)
End = False
for i in range(n + 1):
hantei = True
s = "?" * i + t + "?" * (n - i)
lis = list(s)
for j in range(len(c)):
p = lic[j]
q = lis[j]
a = p == q
if a == False and (p != "?" and q != "?"):
hantei = False
break
if hantei == True:
End = True
ans = lis
if End == True:
for i in range(len(c)):
if lic[i] == "?":
lic[i] = ans[i]
for i in range(len(c)):
if lic[i] == "?":
lic[i] = "a"
lia.append("".join(lic))
sorted(lia)
print(lia[0])
if len(lia) == 0:
print("UNRESTORABLE")
| Statement
Takahashi is a user of a site that hosts programming contests.
When a user competes in a contest, the _rating_ of the user (not necessarily
an integer) changes according to the _performance_ of the user, as follows:
* Let the current rating of the user be a.
* Suppose that the performance of the user in the contest is b.
* Then, the new rating of the user will be the avarage of a and b.
For example, if a user with rating 1 competes in a contest and gives
performance 1000, his/her new rating will be 500.5, the average of 1 and 1000.
Takahashi's current rating is R, and he wants his rating to be exactly G after
the next contest.
Find the performance required to achieve it. | [{"input": "2002\n 2017", "output": "2032\n \n\nTakahashi's current rating is 2002. \nIf his performance in the contest is 2032, his rating will be the average of\n2002 and 2032, which is equal to the desired rating, 2017.\n\n* * *"}, {"input": "4500\n 0", "output": "-4500\n \n\nAlthough the current and desired ratings are between 0 and 4500, the\nperformance of a user can be below 0."}] |
Print the performance required to achieve the objective.
* * * | s278798956 | Wrong Answer | p03563 | Input is given from Standard Input in the following format:
R
G | import sys
sys.setrecursionlimit(4100000)
def inputs(num_of_input):
ins = [input() for i in range(num_of_input)]
return ins
def solve(inputs):
key = inputs[0]
hint = inputs[1]
len_hint = len(hint)
possibility = [] # matched_index
hint_start_i = -1
for i, c in enumerate(key):
if c == hint[0] or c == "?":
possibility.append(0)
new_possibility = []
for matched_hint_index in possibility:
if c == hint[matched_hint_index] or c == "?":
new_possibility.append(matched_hint_index + 1)
if matched_hint_index + 1 == len_hint:
hint_start_i = i - len_hint + 1
break
possibility = new_possibility
if hint_start_i != -1:
break
if hint_start_i == -1:
return "UNRESTORABLE"
resolved_key = ""
for i, c in enumerate(key):
if i == hint_start_i:
resolved_key += hint
elif i >= hint_start_i and i <= hint_start_i + len_hint:
continue
elif c == "?":
resolved_key += "a"
else:
resolved_key += c
return resolved_key
def string_to_int(string):
return list(map(lambda x: int(x), string.split()))
if __name__ == "__main__":
ret = solve(inputs(2))
print(ret)
| Statement
Takahashi is a user of a site that hosts programming contests.
When a user competes in a contest, the _rating_ of the user (not necessarily
an integer) changes according to the _performance_ of the user, as follows:
* Let the current rating of the user be a.
* Suppose that the performance of the user in the contest is b.
* Then, the new rating of the user will be the avarage of a and b.
For example, if a user with rating 1 competes in a contest and gives
performance 1000, his/her new rating will be 500.5, the average of 1 and 1000.
Takahashi's current rating is R, and he wants his rating to be exactly G after
the next contest.
Find the performance required to achieve it. | [{"input": "2002\n 2017", "output": "2032\n \n\nTakahashi's current rating is 2002. \nIf his performance in the contest is 2032, his rating will be the average of\n2002 and 2032, which is equal to the desired rating, 2017.\n\n* * *"}, {"input": "4500\n 0", "output": "-4500\n \n\nAlthough the current and desired ratings are between 0 and 4500, the\nperformance of a user can be below 0."}] |
Print the performance required to achieve the objective.
* * * | s085540976 | Runtime Error | p03563 | Input is given from Standard Input in the following format:
R
G | r = int(input())
g = int(input())
x = (2*g) - r
print(x) | Statement
Takahashi is a user of a site that hosts programming contests.
When a user competes in a contest, the _rating_ of the user (not necessarily
an integer) changes according to the _performance_ of the user, as follows:
* Let the current rating of the user be a.
* Suppose that the performance of the user in the contest is b.
* Then, the new rating of the user will be the avarage of a and b.
For example, if a user with rating 1 competes in a contest and gives
performance 1000, his/her new rating will be 500.5, the average of 1 and 1000.
Takahashi's current rating is R, and he wants his rating to be exactly G after
the next contest.
Find the performance required to achieve it. | [{"input": "2002\n 2017", "output": "2032\n \n\nTakahashi's current rating is 2002. \nIf his performance in the contest is 2032, his rating will be the average of\n2002 and 2032, which is equal to the desired rating, 2017.\n\n* * *"}, {"input": "4500\n 0", "output": "-4500\n \n\nAlthough the current and desired ratings are between 0 and 4500, the\nperformance of a user can be below 0."}] |
Print the performance required to achieve the objective.
* * * | s784810440 | Runtime Error | p03563 | Input is given from Standard Input in the following format:
R
G | import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7
R = i()
G = i()print(R+(G-R)*2) | Statement
Takahashi is a user of a site that hosts programming contests.
When a user competes in a contest, the _rating_ of the user (not necessarily
an integer) changes according to the _performance_ of the user, as follows:
* Let the current rating of the user be a.
* Suppose that the performance of the user in the contest is b.
* Then, the new rating of the user will be the avarage of a and b.
For example, if a user with rating 1 competes in a contest and gives
performance 1000, his/her new rating will be 500.5, the average of 1 and 1000.
Takahashi's current rating is R, and he wants his rating to be exactly G after
the next contest.
Find the performance required to achieve it. | [{"input": "2002\n 2017", "output": "2032\n \n\nTakahashi's current rating is 2002. \nIf his performance in the contest is 2032, his rating will be the average of\n2002 and 2032, which is equal to the desired rating, 2017.\n\n* * *"}, {"input": "4500\n 0", "output": "-4500\n \n\nAlthough the current and desired ratings are between 0 and 4500, the\nperformance of a user can be below 0."}] |
Print the performance required to achieve the objective.
* * * | s702464325 | Runtime Error | p03563 | Input is given from Standard Input in the following format:
R
G | N = int(input())
t = [float(x) for x in input().rsplit()]
v = [float(x) for x in input().rsplit()]
t_0 = 0
t_now = 0
v_0 = 0
v_now = 0
x = 0
t_end = sum(t)
for i in range(N - 1):
if t[i] > v[i] - v_now:
x += (1 / 2) * (v[i] - v_now) ** 2
v_now = v[i]
x += v[i] * (t[i] - (v[i] - v_now))
else:
x += t[i] * t[i] * (1 / 2) + v_now * t[i]
v_now += t[i]
t_now += t[i]
x += (1 / 2) * (t_end - t_now) ** 2
print(x)
| Statement
Takahashi is a user of a site that hosts programming contests.
When a user competes in a contest, the _rating_ of the user (not necessarily
an integer) changes according to the _performance_ of the user, as follows:
* Let the current rating of the user be a.
* Suppose that the performance of the user in the contest is b.
* Then, the new rating of the user will be the avarage of a and b.
For example, if a user with rating 1 competes in a contest and gives
performance 1000, his/her new rating will be 500.5, the average of 1 and 1000.
Takahashi's current rating is R, and he wants his rating to be exactly G after
the next contest.
Find the performance required to achieve it. | [{"input": "2002\n 2017", "output": "2032\n \n\nTakahashi's current rating is 2002. \nIf his performance in the contest is 2032, his rating will be the average of\n2002 and 2032, which is equal to the desired rating, 2017.\n\n* * *"}, {"input": "4500\n 0", "output": "-4500\n \n\nAlthough the current and desired ratings are between 0 and 4500, the\nperformance of a user can be below 0."}] |
Print the performance required to achieve the objective.
* * * | s033649228 | Runtime Error | p03563 | Input is given from Standard Input in the following format:
R
G | n = input('');
k = input('');
int32(1);
for 1:n
min(int32(2)*ans, ans+k);
end
fprintf("%d\n", ans); | Statement
Takahashi is a user of a site that hosts programming contests.
When a user competes in a contest, the _rating_ of the user (not necessarily
an integer) changes according to the _performance_ of the user, as follows:
* Let the current rating of the user be a.
* Suppose that the performance of the user in the contest is b.
* Then, the new rating of the user will be the avarage of a and b.
For example, if a user with rating 1 competes in a contest and gives
performance 1000, his/her new rating will be 500.5, the average of 1 and 1000.
Takahashi's current rating is R, and he wants his rating to be exactly G after
the next contest.
Find the performance required to achieve it. | [{"input": "2002\n 2017", "output": "2032\n \n\nTakahashi's current rating is 2002. \nIf his performance in the contest is 2032, his rating will be the average of\n2002 and 2032, which is equal to the desired rating, 2017.\n\n* * *"}, {"input": "4500\n 0", "output": "-4500\n \n\nAlthough the current and desired ratings are between 0 and 4500, the\nperformance of a user can be below 0."}] |
Print the performance required to achieve the objective.
* * * | s064832863 | Runtime Error | p03563 | Input is given from Standard Input in the following format:
R
G | r=int(input())
g=int(input())
print(2g-r) | Statement
Takahashi is a user of a site that hosts programming contests.
When a user competes in a contest, the _rating_ of the user (not necessarily
an integer) changes according to the _performance_ of the user, as follows:
* Let the current rating of the user be a.
* Suppose that the performance of the user in the contest is b.
* Then, the new rating of the user will be the avarage of a and b.
For example, if a user with rating 1 competes in a contest and gives
performance 1000, his/her new rating will be 500.5, the average of 1 and 1000.
Takahashi's current rating is R, and he wants his rating to be exactly G after
the next contest.
Find the performance required to achieve it. | [{"input": "2002\n 2017", "output": "2032\n \n\nTakahashi's current rating is 2002. \nIf his performance in the contest is 2032, his rating will be the average of\n2002 and 2032, which is equal to the desired rating, 2017.\n\n* * *"}, {"input": "4500\n 0", "output": "-4500\n \n\nAlthough the current and desired ratings are between 0 and 4500, the\nperformance of a user can be below 0."}] |
Print the performance required to achieve the objective.
* * * | s205772967 | Runtime Error | p03563 | Input is given from Standard Input in the following format:
R
G | r = int(input())
g = int(input())
print(r+2g) | Statement
Takahashi is a user of a site that hosts programming contests.
When a user competes in a contest, the _rating_ of the user (not necessarily
an integer) changes according to the _performance_ of the user, as follows:
* Let the current rating of the user be a.
* Suppose that the performance of the user in the contest is b.
* Then, the new rating of the user will be the avarage of a and b.
For example, if a user with rating 1 competes in a contest and gives
performance 1000, his/her new rating will be 500.5, the average of 1 and 1000.
Takahashi's current rating is R, and he wants his rating to be exactly G after
the next contest.
Find the performance required to achieve it. | [{"input": "2002\n 2017", "output": "2032\n \n\nTakahashi's current rating is 2002. \nIf his performance in the contest is 2032, his rating will be the average of\n2002 and 2032, which is equal to the desired rating, 2017.\n\n* * *"}, {"input": "4500\n 0", "output": "-4500\n \n\nAlthough the current and desired ratings are between 0 and 4500, the\nperformance of a user can be below 0."}] |
Print the performance required to achieve the objective.
* * * | s812405423 | Accepted | p03563 | Input is given from Standard Input in the following format:
R
G | import sys
def main():
# Get Args
args = _input_args() # get arguments as an array from console/script parameters.
# Call main Logic
result = _main(args)
# Export a result in a correct way.
_export_result(result)
def _main(args):
"""Write Main Logic here for the contest.
:param args: arguments
:type args: list
:return: result
:rtype: depends on your logic.
"""
# Extract arguments.
R = int(args[0])
G = int(args[1])
# Write main logic here.
X = (2 * G) - R
# Return something.
return X
def _input_args():
# Comment-out appropriate pattern depends on subject.
# arguments = sys.argv[1:] # ptn1: get args from script parameters.
# arguments = _input().split() # ptn2: get args from 1 line console prompt with space separated.
# for multi-line console input, use this.
arguments = _get_args_from_multiple_lines(end_of_lines_char=[""])
# Cast elements If you need.
# arguments = list(map(int, arguments)) # cast elements to int for example.
return arguments # This will be array.
def _input():
# If Subject requires interactive input, use this and patch mock in unittest.
return input() # Change if necessary.
def _get_args_from_multiple_lines(end_of_lines_char=[""]):
"""Get arguments from multiple lines standard input.
:param end_of_lines_char: Strings that indicate the end of lines.
:type end_of_lines_char: list of str
:return: args
:rtype list of str
"""
args = []
while True:
try:
arg = _input()
if arg in end_of_lines_char:
break
args.append(arg)
except EOFError: # Supports EOF Style. (Very Rare case)
break
return args
def _export_result(result):
# Comment-out appropriate output pattern depends on subject.
# sys.stdout.write(result) # No Line Feed, and an result must be string (not useful). for single value output.
# print(result) # The result will cast to strings. Line feed will be appended to the end. for single value output.
# print(result, end='') # Same as above except Line Feed won't be appended. for single value output.
# print(','.join(map(str, result))) # Print array elements as comma separated strings. for multi-value.
print("{}".format(str(result))) # Same as above, but more versatile.
if __name__ == "__main__":
main()
| Statement
Takahashi is a user of a site that hosts programming contests.
When a user competes in a contest, the _rating_ of the user (not necessarily
an integer) changes according to the _performance_ of the user, as follows:
* Let the current rating of the user be a.
* Suppose that the performance of the user in the contest is b.
* Then, the new rating of the user will be the avarage of a and b.
For example, if a user with rating 1 competes in a contest and gives
performance 1000, his/her new rating will be 500.5, the average of 1 and 1000.
Takahashi's current rating is R, and he wants his rating to be exactly G after
the next contest.
Find the performance required to achieve it. | [{"input": "2002\n 2017", "output": "2032\n \n\nTakahashi's current rating is 2002. \nIf his performance in the contest is 2032, his rating will be the average of\n2002 and 2032, which is equal to the desired rating, 2017.\n\n* * *"}, {"input": "4500\n 0", "output": "-4500\n \n\nAlthough the current and desired ratings are between 0 and 4500, the\nperformance of a user can be below 0."}] |
Print the performance required to achieve the objective.
* * * | s158106603 | Runtime Error | p03563 | Input is given from Standard Input in the following format:
R
G | r = int(input().split()[0])
g = int(input().split()[0])
next = g * 2 - r
print(next | Statement
Takahashi is a user of a site that hosts programming contests.
When a user competes in a contest, the _rating_ of the user (not necessarily
an integer) changes according to the _performance_ of the user, as follows:
* Let the current rating of the user be a.
* Suppose that the performance of the user in the contest is b.
* Then, the new rating of the user will be the avarage of a and b.
For example, if a user with rating 1 competes in a contest and gives
performance 1000, his/her new rating will be 500.5, the average of 1 and 1000.
Takahashi's current rating is R, and he wants his rating to be exactly G after
the next contest.
Find the performance required to achieve it. | [{"input": "2002\n 2017", "output": "2032\n \n\nTakahashi's current rating is 2002. \nIf his performance in the contest is 2032, his rating will be the average of\n2002 and 2032, which is equal to the desired rating, 2017.\n\n* * *"}, {"input": "4500\n 0", "output": "-4500\n \n\nAlthough the current and desired ratings are between 0 and 4500, the\nperformance of a user can be below 0."}] |
Print the performance required to achieve the objective.
* * * | s904943808 | Runtime Error | p03563 | Input is given from Standard Input in the following format:
R
G | N = int(input())
t = [0] + list(map(int, input().split()))
v = [0] + list(map(int, input().split()))
T = sum(t)
limit = [0] * (T + 1)
sp_forward = [0] * (T + 1)
sp_backward = [0] * (T + 1)
j = 1
tmp = 0
for i in range(1, T + 1):
limit[i] = v[j]
tmp += 1
if tmp == t[j]:
if j < N - 1 and v[j + 1] < v[j]:
limit[i] = v[j + 1]
j += 1
tmp = 0
for i in range(1, T + 1):
sp_forward[i] = min(sp_forward[i - 1] + 1, limit[i])
for i in reversed(range(0, T)):
sp_backward[i] = min(sp_backward[i + 1] + 1, limit[i])
cnt = 0
for i in range(1, T + 1):
if sp_forward[i - 1] == sp_backward[i] and (
sp_forward[i - 1] < sp_forward[i] or sp_backward[i - 1] > sp_backward[i]
):
cnt += sp_backward[i] + 0.25
elif sp_forward[i - 1] == sp_backward[i]:
cnt += sp_backward[i]
else:
cnt += min(sp_forward[i - 1], sp_backward[i]) + 0.5
print(cnt)
| Statement
Takahashi is a user of a site that hosts programming contests.
When a user competes in a contest, the _rating_ of the user (not necessarily
an integer) changes according to the _performance_ of the user, as follows:
* Let the current rating of the user be a.
* Suppose that the performance of the user in the contest is b.
* Then, the new rating of the user will be the avarage of a and b.
For example, if a user with rating 1 competes in a contest and gives
performance 1000, his/her new rating will be 500.5, the average of 1 and 1000.
Takahashi's current rating is R, and he wants his rating to be exactly G after
the next contest.
Find the performance required to achieve it. | [{"input": "2002\n 2017", "output": "2032\n \n\nTakahashi's current rating is 2002. \nIf his performance in the contest is 2032, his rating will be the average of\n2002 and 2032, which is equal to the desired rating, 2017.\n\n* * *"}, {"input": "4500\n 0", "output": "-4500\n \n\nAlthough the current and desired ratings are between 0 and 4500, the\nperformance of a user can be below 0."}] |
Print the performance required to achieve the objective.
* * * | s019382537 | Runtime Error | p03563 | Input is given from Standard Input in the following format:
R
G | import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**9)
MOD = 10**9 + 7
N = int(input())
T = [0] + list(map(int, input().split()))
V = [0] + list(map(int, input().split()))
max_speed_from_left = [0] * (N + 1)
max_speed_from_right = [0] * (N + 1)
for i in range(1, N):
start = max_speed_from_left[i - 1]
max_speed_from_left[i] = min(start + T[i], V[i], V[i + 1])
for i in range(N - 1, 0, -1):
start = max_speed_from_right[i + 1]
max_speed_from_right[i] = min(start + T[i + 1], V[i], V[i + 1])
speed = [min(x, y) for x, y in zip(max_speed_from_left, max_speed_from_right)]
def dist(left_speed, right_speed, t, v):
x = (v - left_speed) + (v - right_speed)
if x >= t:
v = (left_speed + right_speed) / 2
x = t
d = (left_speed + v) * (v - left_speed) / 2
d += v * (t - x)
d += (right_speed + v) * (v - right_speed) / 2
return d
ans = 0
for i in range(1, N + 1):
ans += dist(speed[i - 1], speed[i], T[i], V[i])
print(ans)
| Statement
Takahashi is a user of a site that hosts programming contests.
When a user competes in a contest, the _rating_ of the user (not necessarily
an integer) changes according to the _performance_ of the user, as follows:
* Let the current rating of the user be a.
* Suppose that the performance of the user in the contest is b.
* Then, the new rating of the user will be the avarage of a and b.
For example, if a user with rating 1 competes in a contest and gives
performance 1000, his/her new rating will be 500.5, the average of 1 and 1000.
Takahashi's current rating is R, and he wants his rating to be exactly G after
the next contest.
Find the performance required to achieve it. | [{"input": "2002\n 2017", "output": "2032\n \n\nTakahashi's current rating is 2002. \nIf his performance in the contest is 2032, his rating will be the average of\n2002 and 2032, which is equal to the desired rating, 2017.\n\n* * *"}, {"input": "4500\n 0", "output": "-4500\n \n\nAlthough the current and desired ratings are between 0 and 4500, the\nperformance of a user can be below 0."}] |
Print the performance required to achieve the objective.
* * * | s217891127 | Accepted | p03563 | Input is given from Standard Input in the following format:
R
G | A = int(input())
B = int(input())
print(2 * B - A)
| Statement
Takahashi is a user of a site that hosts programming contests.
When a user competes in a contest, the _rating_ of the user (not necessarily
an integer) changes according to the _performance_ of the user, as follows:
* Let the current rating of the user be a.
* Suppose that the performance of the user in the contest is b.
* Then, the new rating of the user will be the avarage of a and b.
For example, if a user with rating 1 competes in a contest and gives
performance 1000, his/her new rating will be 500.5, the average of 1 and 1000.
Takahashi's current rating is R, and he wants his rating to be exactly G after
the next contest.
Find the performance required to achieve it. | [{"input": "2002\n 2017", "output": "2032\n \n\nTakahashi's current rating is 2002. \nIf his performance in the contest is 2032, his rating will be the average of\n2002 and 2032, which is equal to the desired rating, 2017.\n\n* * *"}, {"input": "4500\n 0", "output": "-4500\n \n\nAlthough the current and desired ratings are between 0 and 4500, the\nperformance of a user can be below 0."}] |
Print the performance required to achieve the objective.
* * * | s265476842 | Accepted | p03563 | Input is given from Standard Input in the following format:
R
G | print(-1 * int(input()) + 2 * int(input()))
| Statement
Takahashi is a user of a site that hosts programming contests.
When a user competes in a contest, the _rating_ of the user (not necessarily
an integer) changes according to the _performance_ of the user, as follows:
* Let the current rating of the user be a.
* Suppose that the performance of the user in the contest is b.
* Then, the new rating of the user will be the avarage of a and b.
For example, if a user with rating 1 competes in a contest and gives
performance 1000, his/her new rating will be 500.5, the average of 1 and 1000.
Takahashi's current rating is R, and he wants his rating to be exactly G after
the next contest.
Find the performance required to achieve it. | [{"input": "2002\n 2017", "output": "2032\n \n\nTakahashi's current rating is 2002. \nIf his performance in the contest is 2032, his rating will be the average of\n2002 and 2032, which is equal to the desired rating, 2017.\n\n* * *"}, {"input": "4500\n 0", "output": "-4500\n \n\nAlthough the current and desired ratings are between 0 and 4500, the\nperformance of a user can be below 0."}] |
Print the performance required to achieve the objective.
* * * | s301742116 | Accepted | p03563 | Input is given from Standard Input in the following format:
R
G | print(int(input()) * -1 + int(input()) * 2)
| Statement
Takahashi is a user of a site that hosts programming contests.
When a user competes in a contest, the _rating_ of the user (not necessarily
an integer) changes according to the _performance_ of the user, as follows:
* Let the current rating of the user be a.
* Suppose that the performance of the user in the contest is b.
* Then, the new rating of the user will be the avarage of a and b.
For example, if a user with rating 1 competes in a contest and gives
performance 1000, his/her new rating will be 500.5, the average of 1 and 1000.
Takahashi's current rating is R, and he wants his rating to be exactly G after
the next contest.
Find the performance required to achieve it. | [{"input": "2002\n 2017", "output": "2032\n \n\nTakahashi's current rating is 2002. \nIf his performance in the contest is 2032, his rating will be the average of\n2002 and 2032, which is equal to the desired rating, 2017.\n\n* * *"}, {"input": "4500\n 0", "output": "-4500\n \n\nAlthough the current and desired ratings are between 0 and 4500, the\nperformance of a user can be below 0."}] |
Print the performance required to achieve the objective.
* * * | s490737848 | Wrong Answer | p03563 | Input is given from Standard Input in the following format:
R
G | print(-int(input()) + int(input()) << 1)
| Statement
Takahashi is a user of a site that hosts programming contests.
When a user competes in a contest, the _rating_ of the user (not necessarily
an integer) changes according to the _performance_ of the user, as follows:
* Let the current rating of the user be a.
* Suppose that the performance of the user in the contest is b.
* Then, the new rating of the user will be the avarage of a and b.
For example, if a user with rating 1 competes in a contest and gives
performance 1000, his/her new rating will be 500.5, the average of 1 and 1000.
Takahashi's current rating is R, and he wants his rating to be exactly G after
the next contest.
Find the performance required to achieve it. | [{"input": "2002\n 2017", "output": "2032\n \n\nTakahashi's current rating is 2002. \nIf his performance in the contest is 2032, his rating will be the average of\n2002 and 2032, which is equal to the desired rating, 2017.\n\n* * *"}, {"input": "4500\n 0", "output": "-4500\n \n\nAlthough the current and desired ratings are between 0 and 4500, the\nperformance of a user can be below 0."}] |
Print the performance required to achieve the objective.
* * * | s874569726 | Runtime Error | p03563 | Input is given from Standard Input in the following format:
R
G | a
| Statement
Takahashi is a user of a site that hosts programming contests.
When a user competes in a contest, the _rating_ of the user (not necessarily
an integer) changes according to the _performance_ of the user, as follows:
* Let the current rating of the user be a.
* Suppose that the performance of the user in the contest is b.
* Then, the new rating of the user will be the avarage of a and b.
For example, if a user with rating 1 competes in a contest and gives
performance 1000, his/her new rating will be 500.5, the average of 1 and 1000.
Takahashi's current rating is R, and he wants his rating to be exactly G after
the next contest.
Find the performance required to achieve it. | [{"input": "2002\n 2017", "output": "2032\n \n\nTakahashi's current rating is 2002. \nIf his performance in the contest is 2032, his rating will be the average of\n2002 and 2032, which is equal to the desired rating, 2017.\n\n* * *"}, {"input": "4500\n 0", "output": "-4500\n \n\nAlthough the current and desired ratings are between 0 and 4500, the\nperformance of a user can be below 0."}] |
Print the performance required to achieve the objective.
* * * | s758603980 | Runtime Error | p03563 | Input is given from Standard Input in the following format:
R
G | g=int(input())
r=int(input())
print (2r-g)
| Statement
Takahashi is a user of a site that hosts programming contests.
When a user competes in a contest, the _rating_ of the user (not necessarily
an integer) changes according to the _performance_ of the user, as follows:
* Let the current rating of the user be a.
* Suppose that the performance of the user in the contest is b.
* Then, the new rating of the user will be the avarage of a and b.
For example, if a user with rating 1 competes in a contest and gives
performance 1000, his/her new rating will be 500.5, the average of 1 and 1000.
Takahashi's current rating is R, and he wants his rating to be exactly G after
the next contest.
Find the performance required to achieve it. | [{"input": "2002\n 2017", "output": "2032\n \n\nTakahashi's current rating is 2002. \nIf his performance in the contest is 2032, his rating will be the average of\n2002 and 2032, which is equal to the desired rating, 2017.\n\n* * *"}, {"input": "4500\n 0", "output": "-4500\n \n\nAlthough the current and desired ratings are between 0 and 4500, the\nperformance of a user can be below 0."}] |
Print the performance required to achieve the objective.
* * * | s215751271 | Runtime Error | p03563 | Input is given from Standard Input in the following format:
R
G | r, g = map(int, input())
print(-r + 2 * g)
| Statement
Takahashi is a user of a site that hosts programming contests.
When a user competes in a contest, the _rating_ of the user (not necessarily
an integer) changes according to the _performance_ of the user, as follows:
* Let the current rating of the user be a.
* Suppose that the performance of the user in the contest is b.
* Then, the new rating of the user will be the avarage of a and b.
For example, if a user with rating 1 competes in a contest and gives
performance 1000, his/her new rating will be 500.5, the average of 1 and 1000.
Takahashi's current rating is R, and he wants his rating to be exactly G after
the next contest.
Find the performance required to achieve it. | [{"input": "2002\n 2017", "output": "2032\n \n\nTakahashi's current rating is 2002. \nIf his performance in the contest is 2032, his rating will be the average of\n2002 and 2032, which is equal to the desired rating, 2017.\n\n* * *"}, {"input": "4500\n 0", "output": "-4500\n \n\nAlthough the current and desired ratings are between 0 and 4500, the\nperformance of a user can be below 0."}] |
Print the performance required to achieve the objective.
* * * | s508451101 | Runtime Error | p03563 | Input is given from Standard Input in the following format:
R
G | R = int(input())
G = int(input())
print(2G-R) | Statement
Takahashi is a user of a site that hosts programming contests.
When a user competes in a contest, the _rating_ of the user (not necessarily
an integer) changes according to the _performance_ of the user, as follows:
* Let the current rating of the user be a.
* Suppose that the performance of the user in the contest is b.
* Then, the new rating of the user will be the avarage of a and b.
For example, if a user with rating 1 competes in a contest and gives
performance 1000, his/her new rating will be 500.5, the average of 1 and 1000.
Takahashi's current rating is R, and he wants his rating to be exactly G after
the next contest.
Find the performance required to achieve it. | [{"input": "2002\n 2017", "output": "2032\n \n\nTakahashi's current rating is 2002. \nIf his performance in the contest is 2032, his rating will be the average of\n2002 and 2032, which is equal to the desired rating, 2017.\n\n* * *"}, {"input": "4500\n 0", "output": "-4500\n \n\nAlthough the current and desired ratings are between 0 and 4500, the\nperformance of a user can be below 0."}] |
Print the performance required to achieve the objective.
* * * | s837149104 | Wrong Answer | p03563 | Input is given from Standard Input in the following format:
R
G | print(-(int(input()) + int(input())) / 2)
| Statement
Takahashi is a user of a site that hosts programming contests.
When a user competes in a contest, the _rating_ of the user (not necessarily
an integer) changes according to the _performance_ of the user, as follows:
* Let the current rating of the user be a.
* Suppose that the performance of the user in the contest is b.
* Then, the new rating of the user will be the avarage of a and b.
For example, if a user with rating 1 competes in a contest and gives
performance 1000, his/her new rating will be 500.5, the average of 1 and 1000.
Takahashi's current rating is R, and he wants his rating to be exactly G after
the next contest.
Find the performance required to achieve it. | [{"input": "2002\n 2017", "output": "2032\n \n\nTakahashi's current rating is 2002. \nIf his performance in the contest is 2032, his rating will be the average of\n2002 and 2032, which is equal to the desired rating, 2017.\n\n* * *"}, {"input": "4500\n 0", "output": "-4500\n \n\nAlthough the current and desired ratings are between 0 and 4500, the\nperformance of a user can be below 0."}] |
Print the performance required to achieve the objective.
* * * | s353451834 | Runtime Error | p03563 | Input is given from Standard Input in the following format:
R
G | print((int(input())+int(input())/2) | Statement
Takahashi is a user of a site that hosts programming contests.
When a user competes in a contest, the _rating_ of the user (not necessarily
an integer) changes according to the _performance_ of the user, as follows:
* Let the current rating of the user be a.
* Suppose that the performance of the user in the contest is b.
* Then, the new rating of the user will be the avarage of a and b.
For example, if a user with rating 1 competes in a contest and gives
performance 1000, his/her new rating will be 500.5, the average of 1 and 1000.
Takahashi's current rating is R, and he wants his rating to be exactly G after
the next contest.
Find the performance required to achieve it. | [{"input": "2002\n 2017", "output": "2032\n \n\nTakahashi's current rating is 2002. \nIf his performance in the contest is 2032, his rating will be the average of\n2002 and 2032, which is equal to the desired rating, 2017.\n\n* * *"}, {"input": "4500\n 0", "output": "-4500\n \n\nAlthough the current and desired ratings are between 0 and 4500, the\nperformance of a user can be below 0."}] |
Print the performance required to achieve the objective.
* * * | s818905075 | Runtime Error | p03563 | Input is given from Standard Input in the following format:
R
G | a=input()
a=int(a)
s=input()
s=int(s)
2s-a=b
| Statement
Takahashi is a user of a site that hosts programming contests.
When a user competes in a contest, the _rating_ of the user (not necessarily
an integer) changes according to the _performance_ of the user, as follows:
* Let the current rating of the user be a.
* Suppose that the performance of the user in the contest is b.
* Then, the new rating of the user will be the avarage of a and b.
For example, if a user with rating 1 competes in a contest and gives
performance 1000, his/her new rating will be 500.5, the average of 1 and 1000.
Takahashi's current rating is R, and he wants his rating to be exactly G after
the next contest.
Find the performance required to achieve it. | [{"input": "2002\n 2017", "output": "2032\n \n\nTakahashi's current rating is 2002. \nIf his performance in the contest is 2032, his rating will be the average of\n2002 and 2032, which is equal to the desired rating, 2017.\n\n* * *"}, {"input": "4500\n 0", "output": "-4500\n \n\nAlthough the current and desired ratings are between 0 and 4500, the\nperformance of a user can be below 0."}] |
Print the performance required to achieve the objective.
* * * | s101221658 | Runtime Error | p03563 | Input is given from Standard Input in the following format:
R
G | a=int(input())
b=int(input())
print(2b-a) | Statement
Takahashi is a user of a site that hosts programming contests.
When a user competes in a contest, the _rating_ of the user (not necessarily
an integer) changes according to the _performance_ of the user, as follows:
* Let the current rating of the user be a.
* Suppose that the performance of the user in the contest is b.
* Then, the new rating of the user will be the avarage of a and b.
For example, if a user with rating 1 competes in a contest and gives
performance 1000, his/her new rating will be 500.5, the average of 1 and 1000.
Takahashi's current rating is R, and he wants his rating to be exactly G after
the next contest.
Find the performance required to achieve it. | [{"input": "2002\n 2017", "output": "2032\n \n\nTakahashi's current rating is 2002. \nIf his performance in the contest is 2032, his rating will be the average of\n2002 and 2032, which is equal to the desired rating, 2017.\n\n* * *"}, {"input": "4500\n 0", "output": "-4500\n \n\nAlthough the current and desired ratings are between 0 and 4500, the\nperformance of a user can be below 0."}] |
Print the performance required to achieve the objective.
* * * | s586460070 | Runtime Error | p03563 | Input is given from Standard Input in the following format:
R
G | R = int(input())
G = int(input())
print(2G-R) | Statement
Takahashi is a user of a site that hosts programming contests.
When a user competes in a contest, the _rating_ of the user (not necessarily
an integer) changes according to the _performance_ of the user, as follows:
* Let the current rating of the user be a.
* Suppose that the performance of the user in the contest is b.
* Then, the new rating of the user will be the avarage of a and b.
For example, if a user with rating 1 competes in a contest and gives
performance 1000, his/her new rating will be 500.5, the average of 1 and 1000.
Takahashi's current rating is R, and he wants his rating to be exactly G after
the next contest.
Find the performance required to achieve it. | [{"input": "2002\n 2017", "output": "2032\n \n\nTakahashi's current rating is 2002. \nIf his performance in the contest is 2032, his rating will be the average of\n2002 and 2032, which is equal to the desired rating, 2017.\n\n* * *"}, {"input": "4500\n 0", "output": "-4500\n \n\nAlthough the current and desired ratings are between 0 and 4500, the\nperformance of a user can be below 0."}] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.