結果
問題 |
No.944 煎っぞ!
|
ユーザー |
|
提出日時 | 2020-12-21 00:27:29 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 21 ms / 3,000 ms |
コード長 | 1,098 bytes |
コンパイル時間 | 1,634 ms |
コンパイル使用メモリ | 168,252 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-21 12:34:31 |
合計ジャッジ時間 | 3,190 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 35 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; #define mod 1000000007ll #define loop(i, n) for (int i = 0; i < n; i++) #define all(v) v.begin(), v.end() #define putout(a) cout << a << '\n' #define Sum(v) accumulate(all(v), 0ll) template <typename T> bool chmax(T &a, const T &b) { if (a < b) { a = b; // aをbで更新 return true; } return false; } int main() { ll N; cin >> N; vector<ll> A(N); ll maxx = 0; loop(i, N) { cin >> A[i]; chmax(maxx, A[i]); } ll S = Sum(A); for (int i = N; i >= 1; i--) { if (S % i != 0 || (S / i) < maxx) continue; ll now = 0; bool ng = false; ll div = S / i; //各豆のおいしさ loop(j, N) { now += A[j]; if (now > div) { ng = true; break; } if (now == div) now = 0; } if (ng || now != 0) continue; putout(i); return 0; } return 0; }