hr.bash

#335
Raw
Author
winny
Created
Feb. 28, 2021, 6:44 a.m.
Expires
Never
Size
240 bytes
Hits
29
Syntax
Bash
read -r testcases
while ((testcases--)); do
  read -r m
  read -r n
  read -ra costs
  i=0
  j=1
  while :; do
    let sum=costs[i]+costs[j++]
    ((sum == m)) && break
    ((j == n)) && let j=++i+1
  done
  echo $((++i)) $((j))
done