結果
問題 |
No.944 煎っぞ!
|
ユーザー |
![]() |
提出日時 | 2020-02-02 15:25:31 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 26 ms / 3,000 ms |
コード長 | 1,206 bytes |
コンパイル時間 | 1,343 ms |
コンパイル使用メモリ | 118,448 KB |
最終ジャッジ日時 | 2025-01-08 21:51:50 |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 35 |
ソースコード
#include <iostream> #include <cstdio> #include <cstring> #include <vector> #include <deque> #include <queue> #include <array> #include <set> #include <map> #include <cmath> #include <complex> #include <algorithm> #include <numeric> #include <utility> #include <tuple> #include <functional> #include <bitset> #include <cstdint> #include <cassert> #include <random> using namespace std; using i64 = int64_t; using i32 = int32_t; template<class T> T iabs(const T& x) { return max(x, -x); } int n; vector<int> a; int f(int x) { int c = 0; auto it = begin(a); while (it != end(a) - 1) { auto it_next = lower_bound(it, end(a), (c + 1) * x); if (it_next == end(a) || *it_next != (c + 1) * x) { return -1; } it = it_next; c++; } return c; } int main() { cin >> n; a.resize(n); int sum = 0; for (int i = 0; i < n; ++i) { cin >> a[i]; sum += a[i]; if (i > 0) a[i] += a[i - 1]; } int ans = 1; for (int x = 1; x * x <= sum; ++x) { if (sum % x == 0) { ans = max(ans, f(x)); ans = max(ans, f(sum / x)); } } cout << ans << endl; return 0; }