RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
문제 ICPC00136

H. Controllers

설명

You are at your grandparents’ house and you are playing an old video game on a strange console. Your controller has only two buttons and each button has a number written on it. Initially, your score is 0. The game is composed of \(n\) rounds. For each \(1 \le i \le n\), the \(i-th\) round works as follows. On the screen, a symbol \(s_{i}\) appears, which is either + (plus) or - (minus). Then you must press one of the two buttons on the controller once. Suppose you press a button with the number \(x\) written on it: your score will increase by \(x\) if the symbol w\(as + an\)d will decrease by \(x\) if the symbol was -. After you press the button, the round ends. After you have played all \(n\) rounds, you win if your score is 0. Over the years, your grandparents bought many different controllers, so you have \(q\) of them. The two buttons on the \(j-th\) controller have the numbers \(a_{j}\) and \(b_{j}\) written on them. For each controller, you must compute whether you can win the game playing with that controller.

제약
입력 형식

The first line contains a single integer \(n\) (\(1 \le n \le 2 \cdot 10^{5}\)) — the number of rounds. The second line contains a string \(s\) of length \(n\) — where \(s_{i}\) is the symbol that will appear on the screen in the \(i-th\) round. It is guaranteed that \(s\) contains only the characte\(rs + an\)d -. The third line contains an integer \(q\) (\(1 \le q \le 10^{5}\)) — the number of controllers. The following \(q\) lines contain two integers \(a_{j}\) and \(b_{j}\) each (\(1 \le a_{j}\), \(b_{j} \le 10^{9}\)) — the numbers on the buttons of controller \(j\).

출력 형식

Output \(q\) lines. On line \(j\) print YES if the game is winnable using controller \(j\), otherwise print NO.

예제 1
입력
8
+-+---+-
5
2 1
10 3
7 9
10 10
5 3
출력
YES
NO
NO
NO
YES
예제 2
입력
6
+-++--
2
9 7
1 1
출력
YES
YES
예제 3
입력
20
+-----+--+--------+-
2
1000000000 99999997
250000000 1000000000
출력
NO
YES
문제 정보

생성자가 기록되지 않았습니다.

출처 ICPC SWERC 2022

평가 및 의견

H. Controllers

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

H. Controllers

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8