結果
| 問題 | 
                            No.944 煎っぞ!
                             | 
                    
| コンテスト | |
| ユーザー | 
                             t33f
                         | 
                    
| 提出日時 | 2019-12-07 18:04:23 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 34 ms / 3,000 ms | 
| コード長 | 525 bytes | 
| コンパイル時間 | 526 ms | 
| コンパイル使用メモリ | 64,788 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-12-26 01:19:02 | 
| 合計ジャッジ時間 | 2,086 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 35 | 
ソースコード
#include <numeric>
#include <iostream>
using namespace std;
int main() {
    int n; cin >> n;
    int a[n]; for (int i = 0; i < n; i++) cin >> a[i];
    int sum = accumulate(a, a+n, 0), ans = 1;
    for (int i = 1; i <= sum; i++) {
        if (sum % i) continue;
        int m = sum / i;
        bool ok = true;
        for (int i = 0, s = 0; i < n; i++) {
            s += a[i];
            if (s > m) { ok = false; break; }
            if (s == m) s = 0;
        }
        if (ok) ans = i;
    }
    cout << ans << endl;
}
            
            
            
        
            
t33f