結果

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll inf = 2e18;
constexpr ll mod = 998244353;

int t,n,a[300000];
int main(){
    cin >> t;
    while(t--){
        cin >> n;
        ll ans = 0;
        for(int i = 0; i < n; i++){
            cin >> a[i];
            ans += a[i];
        }
        sort(a,a+n);
        if(n == 1){
            cout << 1 << endl;
        }
        else{
            cout << min(ans,2 * (ans - a[n - 1]) + 1) << endl;
        }
    }
}
0