Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int n;
- long long T;
- vector <int> e;
- int main()
- {
- //freopen("YENOM.inp","r",stdin);
- //freopen("YENOM.out","w",stdout);
- //ios_base::sync_with_stdio(0);
- //cin.tie(0); cout.tie(0);
- cin >> n >> T;
- while (n--){
- int a; cin >> a;
- e.push_back(a);
- }
- n = e.back();
- vector <long long> d(n, T+1);
- vector <int> mark(n);
- d[0] = 0;
- for (int i = 1; i < n; ++i)
- {//Dijkstra
- int x = -1;
- for (int j = 0; j < n; ++j)
- if (!mark[j])
- if (x == -1 || d[j] < d[x])
- x = j;
- if (d[x] > T) break;
- mark[x] = 1;
- for (int i : e) {
- int y = (x + i) % n;
- d[y] = min(d[y], d[x] + i);
- }
- }
- long long ans = 0;
- for (int i = 0; i < n; ++i)
- if (d[i] <= T)
- ans += (T - d[i]) / n + 1;
- cout << ans;
- }
Advertisement
Add Comment
Please, Sign In to add comment