結果

問題 No.944 煎っぞ!
ユーザー risujiroh
提出日時 2019-12-07 00:04:05
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 61 ms / 3,000 ms
コード長 578 bytes
コンパイル時間 1,799 ms
コンパイル使用メモリ 174,660 KB
実行使用メモリ 8,448 KB
最終ジャッジ日時 2024-12-24 04:16:41
合計ジャッジ時間 3,463 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 35
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n);
  int sum = 0;
  set<int> se{0};
  for (auto&& e : a) {
    cin >> e;
    sum += e;
    se.insert(sum);
  }
  int res = 0;
  for (int d = 1; d <= sum; ++d) {
    if (sum % d == 0) {
      bool ok = true;
      for (int i = d; i <= sum; i += d) {
        if (not se.count(i)) {
          ok = false;
          break;
        }
      }
      if (ok) {
        res = max(res, sum / d);
      }
    }
  }
  cout << res << '\n';
}
0