結果

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

ソースコード

diff #

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

const ll mod = 1e9 + 7;
const ll mod2 = 998244353;

ll gcd(ll a, ll b) {
    return b ? gcd(b, a % b) : a;
}

ll pow(ll a, ll b) {
    ll ans = 1;
    while (b) {
        if (b & 1) ans *= a;
        b >>= 1;
        a *= a;
    }
    return ans;
}

ll pow(ll a, ll b, ll c) {
    ll ans = 1;
    while (b) {
        if (b & 1) ans = (ans * a) % c;
        b >>= 1;
        a = (a * a) % c;
    }
    return ans;
}

void check(bool b) {
    if (b)
        cout << "Yes\n";
    else
        cout << "No\n";
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int t = 1;
    cin >> t;
    while (t--) {
        ll n;cin>>n;
        vector<ll>a(n);
        for (int i = 0; i < n; ++i) {
            cin>>a[i];
        }
        ll s=accumulate(a.begin(), a.end(), 0ll);
        ll m=*max_element(a.begin(), a.end());
        cout<<s-max(2*m-1-s,0LL)<<'\n';
    }
    return 0;
}
0