AT_abc457_c.Long Sequence

普及-

通过率:0%

时间限制:2.00s

内存限制:1024MB

AC君温馨提醒

该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given integers NN and KK, along with NN integer sequences A1,A2,…,ANA_1, A_2, \ldots, A_N and a length-NN integer sequence C=(C1,C2,…,CN)C = (C_1, C_2, \ldots, C_N). The length of integer sequence AiA_i is LiL_i, and Ai=(Ai,1,Ai,2,…,Ai,Li)A_i = (A_{i,1}, A_{i,2}, \ldots, A_{i,L_i}). It is guaranteed that 1≤K≤∑i=1NCiLi\displaystyle 1 \le K \le \sum_{i=1}^N C_iL_i.

Construct an integer sequence B=(B1,B2,…,B∑i=1NCiLi)B = (B_1, B_2, \ldots, B_{\sum_{i=1}^N C_iL_i}) from AA and CC using the following procedure.

  • Let BB be an integer sequence of length 00.
  • For i=1,2,…,Ni = 1, 2, \ldots, N in this order, perform the following operation:
    • Do this CiC_i times: append AiA_i to the end of BB.

Find the value of BKB_K.

给你整数 NN 和 KK,以及 NN 个整数序列 A1,A2,…,ANA_1, A_2, \ldots, A_N 和一个长度为 NN 的整数序列 C=(C1,C2,…,CN)C = (C_1, C_2, \ldots, C_N)。整数序列 AiA_i 的长度为 LiL_i,且 Ai=(Ai,1,Ai,2,…,Ai,Li)A_i = (A_{i,1}, A_{i,2}, \ldots, A_{i,L_i})。保证 1≤K≤∑i=1NCiLi\displaystyle 1 \le K \le \sum_{i=1}^N C_iL_i。

按照如下步骤,利用 AA 和 CC 构造一个整数序列 B=(B1,B2,…,B∑i=1NCiLi)B = (B_1, B_2, \ldots, B_{\sum_{i=1}^N C_iL_i}):

  • 令 BB 为一个长度为 00 的整数序列。
  • 按照 i=1,2,…,Ni = 1, 2, \ldots, N 的顺序,对每个 ii 执行以下操作:
    • 重复 CiC_i 次:将 AiA_i 追加到 BB 的末尾。

求 BKB_K 的值。

输入格式

The input is given from Standard Input in the following format:

NN KK
L1L_1 A1,1A_{1,1} A1,2A_{1,2} …\ldots A1,L1A_{1,L_1}
L2L_2 A2,1A_{2,1} A2,2A_{2,2} …\ldots A2,L2A_{2,L_2}
⋮\vdots
LNL_N AN,1A_{N,1} AN,2A_{N,2} …\ldots AN,LNA_{N,L_N}
C1C_1 C2C_2 …\ldots CNC_N

输入从标准输入中按以下格式给出:

NN KK
L1L_1 A1,1A_{1,1} A1,2A_{1,2} …\ldots A1,L1A_{1,L_1}
L2L_2 A2,1A_{2,1} A2,2A_{2,2} …\ldots A2,L2A_{2,L_2}
⋮\vdots
LNL_N AN,1A_{N,1} AN,2A_{N,2} …\ldots AN,LNA_{N,L_N}
C1C_1 C2C_2 …\ldots CNC_N

输出格式

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:
BB is constructed as follows:

  • Let B=()B = ().
  • Append A1A_1 to the end of BB once. We get B=(1,3,2)B = (1, 3, 2).
  • Append A2A_2 to the end of BB three times. We get B=(1,3,2,3,3,3)B = (1, 3, 2, 3, 3, 3).
  • Append A3A_3 to the end of BB twice. We get B=(1,3,2,3,3,3,4,3,4,3)B = (1, 3, 2, 3, 3, 3, 4, 3, 4, 3).

For B=(1,3,2,3,3,3,4,3,4,3)B = (1, 3, 2, 3, 3, 3, 4, 3, 4, 3), we have B9=4B_9 = 4, so output 44.

Constraints

  • 1≤N1 \le N
  • 1≤Li1 \le L_i
  • ∑i=1NLi≤2×105\displaystyle \sum_{i=1}^N L_i \le 2 \times 10^5
  • 1≤Ai,j≤1091 \le A_{i,j} \le 10^9 (1≤j≤Li)(1 \le j \le L_i)
  • 1≤Ci≤1091 \le C_i \le 10^9
  • 1≤K≤∑i=1NCiLi\displaystyle 1 \le K \le \sum_{i=1}^N C_iL_i
  • All input values are integers.

样例 1 解释:
BB 的构造过程如下:

  • 令 B=()B = ()。
  • 将 A1A_1 追加到 BB 末尾一次,得到 B=(1,3,2)B = (1, 3, 2)。
  • 将 A2A_2 追加到 BB 末尾三次,得到 B=(1,3,2,3,3,3)B = (1, 3, 2, 3, 3, 3)。
  • 将 A3A_3 追加到 BB 末尾两次,得到 B=(1,3,2,3,3,3,4,3,4,3)B = (1, 3, 2, 3, 3, 3, 4, 3, 4, 3)。

对于 B=(1,3,2,3,3,3,4,3,4,3)B = (1, 3, 2, 3, 3, 3, 4, 3, 4, 3),有 B9=4B_9 = 4,因此输出 44。

约束条件

  • 1≤N1 \le N
  • 1≤Li1 \le L_i
  • ∑i=1NLi≤2×105\displaystyle \sum_{i=1}^N L_i \le 2 \times 10^5
  • 1≤Ai,j≤1091 \le A_{i,j} \le 10^9 (1≤j≤Li)(1 \le j \le L_i)
  • 1≤Ci≤1091 \le C_i \le 10^9
  • 1≤K≤∑i=1NCiLi\displaystyle 1 \le K \le \sum_{i=1}^N C_iL_i
  • 所有输入值均为整数。

输入解题思路,AI测评打分。不知道怎么写?

首页