結果
問題 |
No.3051 Make All Divisible
|
ユーザー |
|
提出日時 | 2025-03-07 21:57:37 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 821 bytes |
コンパイル時間 | 5,777 ms |
コンパイル使用メモリ | 332,436 KB |
実行使用メモリ | 8,612 KB |
最終ジャッジ日時 | 2025-03-07 21:57:44 |
合計ジャッジ時間 | 6,809 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 1 WA * 30 |
ソースコード
#include <bits/stdc++.h> using namespace std; #include <atcoder/all> using namespace atcoder; using mint = atcoder::static_modint<998244353>; // using mint = atcoder::static_modint<1000000007>; using ld = long double; using ll = long long; #define mp(a,b) make_pair(a,b) #define rep(i,s,n) for(int i=s; i<(int)n; i++) const vector<int> dx{1,0,-1,0},dy{0,1,0,-1}; void solve(){ int n,k;cin >> n >> k; vector<ll> a(n);rep(i,0,n)cin >> a[i]; ll sum=0; rep(i,0,n)sum+=a[i]; sum%=k; if(sum!=0){ cout << -1 << "\n"; return; } ll s=0; ll need=0; rep(i,0,n){ s=max(s,a[i]%k); need+=a[i]%k; } need/=k; cout << min(s,need) << "\n"; } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int T;cin >> T; while(T--)solve(); }