1902021-02-04 12:24:45ncsZenehallgatásnimAccepted 50/50111ms51800 KiB
import strscans, strutils, sequtils, sugar, algorithm

var n,k:int
discard scanf(stdin.readLine(),"$i$s$i",n,k)
var T = stdin.readLine().split().map(x=>parseInt(x))
var P = stdin.readLine().split().map(x=>parseInt(x))

var s=0
for i in 0 ..< n:
  s += T[i]
  T[i] = s

for i in 0 ..< k:
  let p = P[i]
  if 0 == p:
    P[i]=1
    continue
  let r = p mod s
  if 0 == r:
    P[i]=n
    continue
  P[i]=lowerBound(T,r)+1 

P.join(" ").echo
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/02ms1960 KiB
2Accepted0/089ms36040 KiB
3Accepted2/23ms4112 KiB
4Accepted2/22ms4036 KiB
5Accepted2/22ms4088 KiB
6Accepted3/33ms4180 KiB
7Accepted3/32ms4120 KiB
8Accepted3/32ms4104 KiB
9Accepted2/2111ms40052 KiB
10Accepted2/292ms41500 KiB
11Accepted2/286ms42964 KiB
12Accepted2/292ms41876 KiB
13Accepted2/279ms45616 KiB
14Accepted2/286ms47020 KiB
15Accepted2/290ms48204 KiB
16Accepted2/282ms49680 KiB
17Accepted2/289ms51800 KiB
18Accepted2/282ms50940 KiB
19Accepted2/2104ms51632 KiB
20Accepted2/282ms49580 KiB
21Accepted2/282ms51584 KiB
22Accepted3/393ms51520 KiB
23Accepted3/386ms51628 KiB
24Accepted3/385ms51672 KiB