結果

問題 No.944 煎っぞ!
ユーザー SSRSSSRS
提出日時 2020-11-12 00:01:43
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 869 ms / 3,000 ms
コード長 724 bytes
コンパイル時間 1,616 ms
コンパイル使用メモリ 177,248 KB
実行使用メモリ 8,836 KB
最終ジャッジ日時 2023-09-30 00:58:34
合計ジャッジ時間 10,190 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 173 ms
8,564 KB
testcase_01 AC 114 ms
8,556 KB
testcase_02 AC 135 ms
8,684 KB
testcase_03 AC 130 ms
8,792 KB
testcase_04 AC 178 ms
8,596 KB
testcase_05 AC 84 ms
8,600 KB
testcase_06 AC 102 ms
8,668 KB
testcase_07 AC 133 ms
8,596 KB
testcase_08 AC 195 ms
8,612 KB
testcase_09 AC 89 ms
8,600 KB
testcase_10 AC 5 ms
4,380 KB
testcase_11 AC 93 ms
4,512 KB
testcase_12 AC 53 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 93 ms
4,452 KB
testcase_15 AC 45 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 93 ms
4,448 KB
testcase_19 AC 92 ms
4,428 KB
testcase_20 AC 349 ms
8,684 KB
testcase_21 AC 383 ms
8,600 KB
testcase_22 AC 109 ms
8,600 KB
testcase_23 AC 147 ms
8,588 KB
testcase_24 AC 211 ms
8,828 KB
testcase_25 AC 126 ms
8,596 KB
testcase_26 AC 114 ms
8,836 KB
testcase_27 AC 869 ms
8,144 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 648 ms
8,620 KB
testcase_31 AC 51 ms
8,596 KB
testcase_32 AC 58 ms
8,536 KB
testcase_33 AC 344 ms
8,600 KB
testcase_34 AC 393 ms
8,336 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++){
    cin >> a[i];
  }
  vector<int> s(N + 1, 0);
  for (int i = 0; i < N; i++){
    s[i + 1] = s[i] + a[i];
  }
  set<int> st;
  for (int i = 0; i <= N; i++){
    st.insert(s[i]);
  }
  vector<int> f;
  for (int i = 1; i * i <= s[N]; i++){
    if (s[N] % i == 0){
      f.push_back(i);
      if (i * i < s[N]){
        f.push_back(s[N] / i);
      }
    }
  }
  sort(f.begin(), f.end());
  for (int x : f){
    bool ok = true;
    for (int i = 0; i <= s[N]; i += x){
      if (!st.count(i)){
        ok = false;
      }
    }
    if (ok){
      cout << s[N] / x << endl;
      break;
    }
  }
}
0