fork download
  1. // وَمَا تَوْفِيقِي إِلَّا بِاللَّهِ عَلَيْهِ تَوَكَّلْتُ وَإِلَيْهِ أُنِيبُ
  2.  
  3. #include <bits/stdc++.h>
  4. #define T int t;cin>>t;while(t--)
  5. #define fast ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
  6. #define endl '\n'
  7. #define int long long
  8. #define F first
  9. #define S second
  10. using namespace std;
  11. const int N = 1e5+5;
  12. void Abady() {
  13. int n; cin >> n;
  14. int arr[n];
  15. for (int i = 0; i < n; i++) cin >> arr[i];
  16. int q; cin >> q;
  17. while (q--) {
  18. int type; cin >> type;
  19. if (type == 1) {
  20. bitset<N> bt;
  21. bt[0] = 1;
  22. vector<int> v;
  23. for (int i=0;i<n;i++) {
  24. if (arr[i]>0) bt |= (bt<<arr[i]);
  25. else v.push_back(arr[i]*-1);
  26. }
  27. for (int i=0;i<v.size();i++) bt |= (bt>>v[i]);
  28. int x; cin >> x;
  29. cout << (bt[x] ? "YES":"NO") << endl;
  30. }
  31. else {
  32. int pos,x; cin >> pos >> x;
  33. arr[pos-1] = x;
  34. }
  35. }
  36. }
  37.  
  38. signed main() {
  39. fast;
  40. Abady();
  41. }
  42.  
Success #stdin #stdout 0.01s 5288KB
stdin
Standard input is empty
stdout
Standard output is empty