Dmaxiya

[蓝桥杯 2026 省 B] 蓝桥竞技 参考代码

Apr 11th, 2026
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.92 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define endl '\n'
  5.  
  6. typedef long long LL;
  7. const int maxn = 100000 + 100;
  8. int T, n;
  9. LL sum, avg;
  10. LL a[maxn];
  11.  
  12. int main() {
  13.     ios::sync_with_stdio(false);
  14.  
  15.     cin >> T;
  16.     while (T--) {
  17.         cin >> n;
  18.         sum = 0;
  19.         for (int i = 1; i <= n; ++i) {
  20.             cin >> a[i];
  21.             sum += a[i];
  22.         }
  23.         if (sum == 0) {
  24.             cout << "T" << endl;
  25.             continue;
  26.         }
  27.         if (n < 5) {
  28.             cout << "F" << endl;
  29.             continue;
  30.         }
  31.         if (sum % 5 != 0) {
  32.             cout << "F" << endl;
  33.             continue;
  34.         }
  35.         avg = sum / 5;
  36.         bool flag = true;
  37.         for (int i = 1; i <= n; ++i) {
  38.             if (a[i] > avg) {
  39.                 flag = false;
  40.                 break;
  41.             }
  42.         }
  43.         cout << (flag ? "T" : "F") << endl;
  44.     }
  45.  
  46.     return 0;
  47. }
  48.  
Advertisement
Add Comment
Please, Sign In to add comment