#include <bits/stdc++.h> typedef long long ll; const int maxn = 100010; const int inf = 0x3f3f3f3f; using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int t, n, a, b, c, d; cin >> t; while (t--) { cin >> n >> a >> b >> c >> d; int minn1 = a - b; int minn2 = c - d; int maxx1 = a + b; int maxx2 = c + d; if (maxx1 * n < minn2 || minn1 * n > maxx2) cout << "NO" << endl; else cout << "YES" << endl; } return 0; }
#include <bits/stdc++.h> typedef long long ll; const int maxn = 200010; const int inf = 0x3f3f3f3f; using namespace std; int a[maxn], sum[maxn]; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int t, n, m; cin >> t; while (t--) { cin >> n >> m; for (int i = 1; i <= n; i++) cin >> a[i]; memset(sum, 0, sizeof(sum)); int k = 0, l = 1; for (int i = 2; i <= n; i++) { if (a[i] > a[i - 1] && a[i] > a[i + 1] && i < n) sum[i] = sum[i - 2] + 1; else sum[i] = sum[i - 1]; if (i >= m && sum[i - 1] - sum[i - m + 1] + 1 > k) { l = i - m + 1; k = sum[i - 1] - sum[i - m + 1] + 1; } } cout << k << " " << l << endl; } return 0; }
#include <bits/stdc++.h> typedef long long ll; const int maxn = 100010; const int inf = 0x3f3f3f3f; using namespace std; int a[maxn]; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int t, n; cin >> t; while (t--) { cin >> n; for (int i = 1; i <= n; i++) cin >> a[i]; int ans = 1, flag = 1; for (int i = n; i; i--) { if (ans == a[i]) ans++; else if (ans < a[i]) ans = a[i]; else if (a[i + 1] - a[i] != 1) { flag = 0; break; } } if (flag) cout << "YES" << endl; else cout << "NO" << endl; } return 0; }