#include<iostream> #include<algorithm> #include<vector> usingnamespace std; voidsolve(){ int x, t, k, n, d; cin >> x >> t >> k >> n >> d; t = min(t, n); vector<int>v(n, 1); int sum = 0; for (int i = 0; i < n; i++) { int u; cin >> u; if (u <= d) v[i] = -1; sum += v[i]; } if (sum < 0) { cout << "YES\n"; return; } int cnt = 0; for (int i = 0; i < n; i++) { x += v[i]; if (x <= k) cnt++; else cnt = 0; if (cnt >= t) { cout << "YES\n"; return; } } for (int i = 0; i < n; i++) { x += v[i]; if (x <= k) cnt++; else cnt = 0; if (cnt >= t) { cout << "YES\n"; return; } } cout << "NO\n"; } intmain(){ ios::sync_with_stdio(0); cin.tie(0); int t; cin >> t; while (t--) solve(); return0; }
#include<iostream> #include<cstring> #include<vector> #define int long long usingnamespace std; typedef pair<int, int> PII; constint N = 510; int n, m; vector<PII> e[N]; int dist[N][N];//第一维 记录路过多少个节点 第二维 节点i voidDeal() { for (int i = 0; i <= n; i++) { for (int j = 0; j <= n; j++) { dist[i][j] = 3e18; } } dist[0][1] = 0; for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { for (auto t : e[j]) { dist[i][j] = min(dist[i][j], dist[i - 1][t.first] + t.second); } } } } voidsolve() { cin >> n >> m; for (int i = 1; i <= m; i++) { int u, v, t; cin >> u >> v >> t; e[u].push_back({ v, t }); e[v].push_back({ u, t }); } Deal(); int q; cin >> q; while (q--) { int t; cin >> t; int sum = 0, res = 3e18; for (int i = 1; i <= n - 1; i++) { int x; cin >> x, sum += x; res = min(res, dist[i][t] + sum); } cout << res << '\n'; } } signedmain() { ios::sync_with_stdio(0); cin.tie(0); solve(); return0; }