1 条题解
-
0
对于 操作:选择的数字能提供的贡献就是本身的数值大小
对于 操作:
- 如果 ,
- 如果 ,
- 如果 ,
可以看到只有前两种的贡献是比 sum 操作要高的,并且第一个和第二个 提供的贡献相同。
所以我们对所有 选择 操作,其他数字选择 操作。
#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; void solve() { int n; cin >> n; int ans = 0; for(int i = 1; i <= n; i ++) { int x; cin >> x; ans += max(1, x); } cout << ans << endl; } int main() { ios::sync_with_stdio(false); cin.tie(0); int t = 1; cin >> t; while(t --) solve(); }
- 1
信息
- ID
- 505
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 10
- 标签
- 递交数
- 13
- 已通过
- 1
- 上传者