AT_abc457_c.Long Sequence
普及-
通过率:0%
时间限制:2.00s
内存限制:1024MB
AC君温馨提醒
该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given integers N and K, along with N integer sequences A1,A2,…,AN and a length-N integer sequence C=(C1,C2,…,CN). The length of integer sequence Ai is Li, and Ai=(Ai,1,Ai,2,…,Ai,Li). It is guaranteed that 1≤K≤i=1∑NCiLi.
Construct an integer sequence B=(B1,B2,…,B∑i=1NCiLi) from A and C using the following procedure.
- Let B be an integer sequence of length 0.
- For i=1,2,…,N in this order, perform the following operation:
- Do this Ci times: append Ai to the end of B.
Find the value of BK.
给你整数 N 和 K,以及 N 个整数序列 A1,A2,…,AN 和一个长度为 N 的整数序列 C=(C1,C2,…,CN)。整数序列 Ai 的长度为 Li,且 Ai=(Ai,1,Ai,2,…,Ai,Li)。保证 1≤K≤i=1∑NCiLi。
按照如下步骤,利用 A 和 C 构造一个整数序列 B=(B1,B2,…,B∑i=1NCiLi):
- 令 B 为一个长度为 0 的整数序列。
- 按照 i=1,2,…,N 的顺序,对每个 i 执行以下操作:
- 重复 Ci 次:将 Ai 追加到 B 的末尾。
求 BK 的值。
输入格式
The input is given from Standard Input in the following format:
N K
L1 A1,1 A1,2 … A1,L1
L2 A2,1 A2,2 … A2,L2
⋮
LN AN,1 AN,2 … AN,LN
C1 C2 … CN
输入从标准输入中按以下格式给出:
N K
L1 A1,1 A1,2 … A1,L1
L2 A2,1 A2,2 … A2,L2
⋮
LN AN,1 AN,2 … AN,LN
C1 C2 … CN
输出格式
Output the answer.
输出答案。
输入输出样例
输入#1
3 9 3 1 3 2 1 3 2 4 3 1 3 2
输出#1
4
输入#2
3 1 1 7 1 111 1 5 1 100 10000
输出#2
7
输入#3
3 3163812 5 1 2 3 4 5 4 9 8 7 6 2 10 11 87043 908415 9814
输出#3
9
说明/提示
Sample 1 Explanation:
B is constructed as follows:
- Let B=().
- Append A1 to the end of B once. We get B=(1,3,2).
- Append A2 to the end of B three times. We get B=(1,3,2,3,3,3).
- Append A3 to the end of B twice. We get B=(1,3,2,3,3,3,4,3,4,3).
For B=(1,3,2,3,3,3,4,3,4,3), we have B9=4, so output 4.
Constraints
- 1≤N
- 1≤Li
- i=1∑NLi≤2×105
- 1≤Ai,j≤109 (1≤j≤Li)
- 1≤Ci≤109
- 1≤K≤i=1∑NCiLi
- All input values are integers.
样例 1 解释:
B 的构造过程如下:
- 令 B=()。
- 将 A1 追加到 B 末尾一次,得到 B=(1,3,2)。
- 将 A2 追加到 B 末尾三次,得到 B=(1,3,2,3,3,3)。
- 将 A3 追加到 B 末尾两次,得到 B=(1,3,2,3,3,3,4,3,4,3)。
对于 B=(1,3,2,3,3,3,4,3,4,3),有 B9=4,因此输出 4。
约束条件
- 1≤N
- 1≤Li
- i=1∑NLi≤2×105
- 1≤Ai,j≤109 (1≤j≤Li)
- 1≤Ci≤109
- 1≤K≤i=1∑NCiLi
- 所有输入值均为整数。
输入解题思路,AI测评打分。不知道怎么写?