結果

問題 No.1823 Tricolor Dango
ユーザー sk10271879sk10271879
提出日時 2022-10-03 19:55:07
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 77 ms / 2,000 ms
コード長 2,173 bytes
コンパイル時間 2,042 ms
コンパイル使用メモリ 199,520 KB
実行使用メモリ 4,628 KB
最終ジャッジ日時 2023-08-27 18:13:16
合計ジャッジ時間 5,891 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 47 ms
4,376 KB
testcase_02 AC 47 ms
4,380 KB
testcase_03 AC 46 ms
4,380 KB
testcase_04 AC 29 ms
4,380 KB
testcase_05 AC 29 ms
4,380 KB
testcase_06 AC 29 ms
4,376 KB
testcase_07 AC 26 ms
4,380 KB
testcase_08 AC 24 ms
4,376 KB
testcase_09 AC 29 ms
4,376 KB
testcase_10 AC 28 ms
4,376 KB
testcase_11 AC 29 ms
4,376 KB
testcase_12 AC 23 ms
4,376 KB
testcase_13 AC 27 ms
4,376 KB
testcase_14 AC 30 ms
4,376 KB
testcase_15 AC 25 ms
4,376 KB
testcase_16 AC 11 ms
4,376 KB
testcase_17 AC 15 ms
4,380 KB
testcase_18 AC 28 ms
4,376 KB
testcase_19 AC 77 ms
4,628 KB
testcase_20 AC 28 ms
4,376 KB
testcase_21 AC 36 ms
4,380 KB
testcase_22 AC 45 ms
4,380 KB
testcase_23 AC 30 ms
4,376 KB
testcase_24 AC 36 ms
4,376 KB
testcase_25 AC 45 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std; using ll=long long; using Pa=pair<ll,ll>; using Vll=vector<ll>; using VVll=vector<Vll>; using Vb=vector<bool>; using VVb=vector<vector<bool>>; using Vs=vector<string>; using VVs =vector<vector<string>>; using Vc=vector<char>; using VVc =vector<vector<char>>; const ll MOD=1000000007; const ll INF=(ll)1<<60;// 10^18 < 1<<60 = 1152921504606846976 // VVll G(N+1,Vll(0));   // vector<Pa> event; event.emplace_back(a,b); // 以下の関数 oi:エラー出力  OI:正出力  OIV:1次元vector正出力  OIVV:2次元vector正出力 
template<class t,class u> bool chmax(t&a,u b){if(a<b){a=b; return true;} else{return false;}}template<class t,class u> bool chmin(t&a,u b){if(b<a){a=b; return true;} else{return false;}} void oi(){}template<class Head, class... Tail>void oi(Head&& head,Tail&&... tail){if(sizeof...(tail)!=0){cerr<<head<<" ";} else{cerr<<head<<"\n";}oi(move(tail)...);} void OI(){}template<class Head, class... Tail>void OI(Head&& head,Tail&&... tail){if(sizeof...(tail)!=0){cout<<head<<" ";} else{cout<<head<<"\n";}OI(move(tail)...);} void OIV(){}template<typename T> void OIV(T &a){if(a.empty()){cout<<"\n"; return;} for(ll i00=0;i00<(a).size();i00++){if(a[i00]==(ll)1<<60){cout<<"I";} else{cout<<a[i00];} if(i00==(a).size()-1){cout<<"\n";} else{cout<<" ";}}} void OIVV(){}template<typename T> void OIVV(T &a){if(a.empty()){cout<<"\n"; return;} for(ll i00=0;i00<(a).size();i00++){for(ll j00=0;j00<(a[i00]).size();j00++){if(a[i00][j00]==(ll)1<<60){cout<<"I";} else{cout<<a[i00][j00];} if(j00==(a[i00]).size()-1){cout<<"\n";} else{cout<<" ";}}}}
#define FOR(i,a,b) for(ll i=(ll)(a); i<(ll)(b); i++)// a ~ b-1 i++ 
#define ALL(a) (a).begin(),(a).end()//   printf("%8.10lf\n",(ans));

int main(){
    ll T; cin>>T;
    FOR(_,0,T){
        ll N; cin>>N;
        Vll A(N); FOR(i,0,N) cin>>A[i];

        ll cnt=0;
        FOR(i,0,N){
            cnt+=A[i];
        }
        if(cnt%3!=0){OI("No"); continue;}

        ll max=cnt/3;
        bool ok=true;
        FOR(i,0,N){
            if(A[i]>max) ok=false;// どこかに2個以上つく
        }
        if(ok) OI("Yes");
        else OI("No");
    }

    return 0;
}
0