結果

問題 No.944 煎っぞ!
コンテスト
ユーザー ianCK
提出日時 2019-12-09 03:56:04
言語 C++11(廃止可能性あり)
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 16 ms / 3,000 ms
コード長 552 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 138 ms
コンパイル使用メモリ 41,248 KB
実行使用メモリ 7,720 KB
最終ジャッジ日時 2026-03-04 10:06:25
合計ジャッジ時間 1,618 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 35
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <stdio.h>

constexpr int kN = int(1E5 + 10), kC = int(1E7 + 10);


int a[kN], n;

bool ok(int x) {
	int now = 0;
	for (int i = 1; i <= n; i++) {
		if (now + a[i] > x) return false;
		else now += a[i];
		if (now == x) now = 0;
	}
	return true;
}



int main() {
	int tot = 0, ans = 1;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
	for (int i = 1; i <= n; i++) tot += a[i];
	for (int i = 1; i <= tot; i++) if (tot % i == 0) {
		if (ok(i)) {
			printf("%d\n", tot / i);
			return 0;
		}
	}
}
0