Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * author: compounding
- * created: 2024-12-14 18:07:38
- **/
- #include <bits/stdc++.h>
- using namespace std;
- mt19937_64 RNG(chrono::steady_clock::now().time_since_epoch().count());
- #define NeedForSpeed \
- ios_base::sync_with_stdio(false); \
- cin.tie(NULL); \
- cout.tie(NULL);
- #define int long long
- #define all(x) (x).begin(), (x).end()
- typedef vector<int> vi;
- #define yes cout << "Yes" << endl
- #define no cout << "No" << endl
- #define endl "\n"
- void solve()
- {
- int n, s;
- cin >> n >> s;
- vi a(n);
- int sum = 0;
- for (int i = 0; i < n; i++)
- {
- cin >> a[i];
- sum += a[i];
- }
- if (s % sum == 0 && s / sum > 0)
- {
- yes;
- return;
- }
- int rem = s % sum, cur = 0;
- map<int, int> seen;
- seen[0] = 1;
- // 2 * n is enough
- for (int i = 0; i < 2 * n; i++)
- {
- cur += a[i % n];
- if (seen.count(cur - rem))
- {
- yes;
- return;
- }
- seen[cur] = 1;
- }
- no;
- }
- signed main()
- {
- NeedForSpeed;
- int t = 1;
- // cin >> t;
- while (t--)
- solve();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment