Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define ll long long
- int main()
- {
- int MOD = 998244353;
- int q, k;
- cin>>q>>k;
- vector<ll int> ways(5100);
- ways[0] = 1;
- while(q--)
- {
- char ch;
- int x;
- cin>>ch>>x;
- if(ch == '+')
- for(int i=k-x; i>=0; i--) (ways[i+x] += ways[i]) %= MOD;
- if(ch == '-')
- for(int i=0; i<=k-x; i++) (ways[i+x] += (MOD-ways[i])) %= MOD;
- cout<<ways[k]<<"\n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment