题解:CF2074B The Third Side
题目简述
给定长度为
重复操作直到
主要思路
小学数学题。要想组成三角形,就要满足两边之和大于第三边。想要最后剩的值最大,
每次选择两个数,总共就要选择
AC Code
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef long double db;
const int N = 2e5 + 10;
const int INT_INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
// ----------------------------
// ----------------------------
// ----------------------------
int main() {
int t; cin >> t;
// ----------------------------
int n, a, sum;
while (t--) {
cin >> n;
sum = 0;
for (int i = 1; i <= n; i++) {
cin >> a;
sum += a;
}
sum -= n - 1;
cout << sum << '\n';
}
return 0;
}