結果

問題 No.1823 Tricolor Dango
ユーザー blackyukiblackyuki
提出日時 2022-01-28 21:23:53
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 84 ms / 2,000 ms
コード長 536 bytes
コンパイル時間 2,043 ms
コンパイル使用メモリ 200,084 KB
実行使用メモリ 4,588 KB
最終ジャッジ日時 2023-08-28 19:02:44
合計ジャッジ時間 3,953 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 53 ms
4,376 KB
testcase_02 AC 52 ms
4,380 KB
testcase_03 AC 53 ms
4,380 KB
testcase_04 AC 33 ms
4,376 KB
testcase_05 AC 33 ms
4,376 KB
testcase_06 AC 34 ms
4,380 KB
testcase_07 AC 30 ms
4,380 KB
testcase_08 AC 27 ms
4,376 KB
testcase_09 AC 32 ms
4,380 KB
testcase_10 AC 32 ms
4,380 KB
testcase_11 AC 33 ms
4,380 KB
testcase_12 AC 27 ms
4,380 KB
testcase_13 AC 32 ms
4,380 KB
testcase_14 AC 35 ms
4,376 KB
testcase_15 AC 28 ms
4,380 KB
testcase_16 AC 12 ms
4,380 KB
testcase_17 AC 17 ms
4,376 KB
testcase_18 AC 32 ms
4,380 KB
testcase_19 AC 84 ms
4,588 KB
testcase_20 AC 31 ms
4,376 KB
testcase_21 AC 41 ms
4,380 KB
testcase_22 AC 51 ms
4,380 KB
testcase_23 AC 35 ms
4,376 KB
testcase_24 AC 41 ms
4,380 KB
testcase_25 AC 50 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main(){
    int t;cin>>t;
    for(int tt=0;tt<t;tt++){
    int n, k=3; cin >> n;
    vector<long long> v(n);
    for(long long &x : v) cin >> x;
    long long ok = 0, ng = 1e18 / k;
    while(ng - ok > 1){
        long long md = (ok + ng) / 2, sum = 0;
        for(long long x : v) sum += min(x, md);
        if(sum >= k * md) ok = md;
        else ng = md;
    }
    long long sum=0;
    for(long long x:v)sum+=x;
    if(3*ok==sum)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    }
}
0