1 条题解
-
0
结论: 让 ,对于每一个 ,当且仅当 成立时,才能实现 。
构造:
从左到右建立数组。对于每一个 ,如果有 ,那么我们直接添加 。否则,我们首先添加 ,然后再添加 。
证明:
假设存在 , 设最小值下标为 , 即存在 其中 。
考虑 点的构成.
-
如果添加的值 , 那么值会加在 点, 假设不成立。
-
如果添加的值 ,此时值不够,需要第二次添加,但是第二次添加的值会优先加在 点上,假设不成立。
-
如果添加的值 ,第二次最大能添加的值为 , 超过的话值会加在 点。其中第一次添加的范围是 。那么最后能取得的范围为 .
假设不成立,最初结论成立。
#include<bits/stdc++.h> using namespace std; typedef long long LL; typedef pair<int, int> PII; #define x first #define y second const int N = 2e5 + 10, mod = 998244353; int qmi(int a, int k) { int res = 1; while (k) { if (k & 1) res = (LL)res * a % mod; a = (LL)a * a % mod; k >>= 1; } return res; } void solve() { int n; cin >> n; vector<int> a(n + 1); for(int i = 1; i <= n; i ++) cin >> a[i]; int x = 1e9; for(int i = 1; i <= n; i ++) { int t = (x - 1) * 2 + 1; if(a[i] > t) { cout<< "NO\n"; return; } x = min(x, a[i]); } cout <<"YES\n"; } int main() { ios::sync_with_stdio(false); cin.tie(0); int t = 1; cin >> t; while(t --) solve(); } -
- 1
信息
- ID
- 503
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 10
- 标签
- 递交数
- 7
- 已通过
- 2
- 上传者