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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
|
#include <iostream> #include <algorithm> #include <cstring> #include <cmath> #include <queue> #include <vector> #include <set> #include <map> #include <stack> #include <unordered_map> using namespace std;
#define fast_ ios::sync_with_stdio(0); cout.tie(0); cin.tie(0);
#define ffi(a, b) for(int i = a; i <= b; i ++) #define ffj(a, b) for(int j = a; j <= b; j ++) #define ffk(a, b) for(int k = a; k <= b; k ++)
int qpow(int a, int b, int mod) { int res = 1; while(b) { if(b & 1) res = (res * a) % mod; b >>= 1; a = (a * a) % mod;} return res; }
#define pb push_back #define ins insert #define piii pair<pair<int, int>, int> #define pii pair<int, int> #define umap unordered_map #define int long long
const int N = 2e5 + 10, mod = 1e9 + 7;
int n, m, qq; int a[N], b[N], c[N], d[N]; string s;
void solve() { cin >> n >> m; for(int i = 1; i <= n ;i ++) cin >> a[i]; string s; cin >> s; for(int i = 1; i <= n ; i ++) if(s[i - 1] == '+') b[i] = b[i - 1] + a[i]; else b[i] = b[i - 1] - a[i]; c[0] = d[n + 1] = 0x3f3f3f3f3f3f3f3f; for(int i = 1; i <= n; i ++) c[i] = min(c[i - 1], b[i]); for(int i = n ; i >= 1; i --) d[i] = min(d[i + 1], b[i]); int pp = 1e18, idx = -1; for(int i = 1; i <= n ;i ++) { if(c[i] < 0) { pp = c[i]; idx = i; break; } } while( m --) { int x; char t; cin >> x >> t; if(s[x - 1] != t) { if(t == '-') { if(c[x - 1] < 0) cout << "NO\n"; else if(d[x] >= 2 * a[x]) cout << "YES\n"; else cout << "NO\n"; } else { if(c[x - 1] < 0) cout << "NO\n"; else if(d[x] >= -2 * a[x])cout << "YES\n"; else cout << "NO\n"; } } else { if(idx == -1)cout << "YES\n"; else cout << "NO\n"; } } }
void Coding() { fast_; int t = 1; #ifdef MORE cin >> t; #endif while(t --) solve(); }
signed main() { Coding(); return 0; }
|