Logo
(追記) (追記ここまで)

29883번 - Practice 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB53342661.905%

문제

John practiced for $N$ days in preparation for the olympiad. He solved $X_i$ tasks on day $i$.

After the olympiad he wanted to know whether there was a span of consecutive days when he solved exacly $Y$ tasks. In other words, are there integers $a$ and $b$ such that 1ドル \le a \le b \le N$ and $X_a + X_{a+1} + \ldots + X_b = Y$?

Write a program to help John answer that question.

입력

The first line of input contains $N,ドル the number of days (1ドル \le N \le 1,000円$), and $M,ドル the number of questions (1ドル \le M \le 1,000円,000円$).

The second line contains $N$ space-separated integers $X_i$ (0ドル \le X_i \le 1,000円,ドル where 1ドル \le i \le N$), the numbers of tasks John solved each day.

The third line contains $M$ space-separated integers $Y_j$ (1ドル \le Y_j \le 1,000円,000円,ドル where 1ドル \le j \le M$), the numbers of tasks in John's questions.

출력

Output $M$ lines, one per question. On the line $j$ output the word 'JAH', if there exists a span of consecutive days when John solved exactly $Y_j$ tasks, or the word 'EI', if there's no such span of days.

제한

예제 입력 1

3 4
1 2 3
2 7 5 4

예제 출력 1

JAH
EI
JAH
EI

John solved 2ドル$ tasks on the seocnd day, so the answer to the first question is 'JAH'. As he only solved 6ドル$ tasks in total, the answer to the second question is obviously 'EI'. From the second to the third day, he solved 2ドル + 3 = 5$ tasks, so the answer to the third question is 'JAH'. As there is no span of consecutive days when he solved 4ドル$ tasks in total, the answer to the last question is 'EI'.

힌트

출처

Olympiad > Estonian Informatics Olympiad > 2020-21 > Open Competition 3번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /