結果

問題 No.3051 Make All Divisible
ユーザー pockyny
提出日時 2025-07-13 12:00:46
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 590 bytes
コンパイル時間 1,511 ms
コンパイル使用メモリ 68,328 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2025-07-13 12:00:50
合計ジャッジ時間 1,821 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 1 WA * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>

using namespace std;
typedef long long ll;
ll a[200010];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t; cin >> t;
    while(t){
        t--;
        ll i,n,k; cin >> n >> k;
        for(i=0;i<n;i++) cin >> a[i];
        ll sum = 0;
        for(i=0;i<n;i++) sum += a[i];
        if(sum%k!=0){
            cout << -1 << "\n";
            continue; 
        }
        ll mx = -1;
        sum = 0;
        for(i=0;i<n;i++){
            mx = max(mx,a[i]%k);
            sum += a[i]%k;
        }
        cout << min(mx,sum/k) << "\n";
    }
}
0