1 条题解
-
0
每个人取得的糖果数量受两个条件限制,设第 个人取得的糖果数为 .
- 至少要 个:
- 比前面的人多:
第 个人取得 为最小值
#include<bits/stdc++.h> using namespace std; typedef long long LL; typedef pair<LL, LL> PII; #define x first #define y second const int N = 5e3 + 10, mod = 1e9 + 7; int a[N]; int main() { int n; cin >> n; LL ans = 0; for(int i = 1; i <= n; i ++) { cin >> a[i]; a[i] = max(a[i - 1] + 1, a[i]); ans += a[i]; } cout << ans << endl; }
- 1
信息
- ID
- 195
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 2
- 标签
- 递交数
- 16
- 已通过
- 11
- 上传者