結果
| 問題 | 
                            No.944 煎っぞ!
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2019-12-09 03:56:10 | 
| 言語 | C++11(廃止可能性あり)  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 26 ms / 3,000 ms | 
| コード長 | 552 bytes | 
| コンパイル時間 | 148 ms | 
| コンパイル使用メモリ | 23,040 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-06-11 07:43:20 | 
| 合計ジャッジ時間 | 1,544 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 35 | 
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:22:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   22 |         scanf("%d", &n);
      |         ~~~~~^~~~~~~~~~
main.cpp:23:43: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   23 |         for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
      |                                      ~~~~~^~~~~~~~~~~~~
            
            ソースコード
#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;
		}
	}
}