-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathControllers.cpp
More file actions
43 lines (40 loc) · 864 Bytes
/
Copy pathControllers.cpp
File metadata and controls
43 lines (40 loc) · 864 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Codeforces Problem: L - Controllers
// Link: https://codeforces.com/contest/1776/problem/L
// Status: Accepted Language: C++
#include<iostream>
using namespace std;
#define ll long long
int main () {
ll n, q, p = 0, m = 0;
cin>>n;
for (int i = 0; i < n; i++) {
char c;
cin>>c;
if (c == '+') {
p++;
} else {
m++;
}
}
cin>>q;
while (q--) {
ll x, y;
cin>>x>>y;
if (p == m) {
cout<<"YES\n";
continue;
}
ll numr = (m - p) * y, denm = x - y;
if (denm == 0 || numr % denm != 0) {
cout<<"NO\n";
continue;
}
ll k = numr / denm;
if (k >= -m && k <= p) {
cout<<"YES\n";
} else {
cout<<"NO\n";
}
}
return 0;
}