結果

問題 No.3165 [Cherry 7th Tune A] Croissants Continu
ユーザー HoyHoyCharhang
提出日時 2025-05-30 21:43:03
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 228 ms / 2,000 ms
コード長 1,016 bytes
コンパイル時間 3,810 ms
コンパイル使用メモリ 278,236 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2025-05-30 21:43:46
合計ジャッジ時間 7,849 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,s,n) for (int i = (s); i < (n); ++i)
#define rrep(i,n,g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define len(x) (int)(x).size()
#define dup(x,y) (((x)+(y)-1)/(y))
#define pb push_back
#define eb emplace_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using ull = unsigned long long;
template<typename T> using pq = priority_queue<T,vector<T>,greater<T>>;
using P = pair<int,int>;
template<class T>bool chmax(T&a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T&a,T b){if(b<a){a=b;return 1;}return 0;}

int main() {
  int t;
  cin >> t;
  while(t--) {
    int n;
    cin >> n;
    vector<int> a(n);
    ll s = 0; int m = 0;
    rep(i,0,n) {
      cin >> a[i];
      s += a[i];
      m = max(m, a[i]);
    }
    if ((s+1)/2 >= m) {
      cout << s << endl;
    } else {
      cout << (s-m)*2+1 << endl;
    }
  }
  return 0;
}
0