結果
| 問題 |
No.944 煎っぞ!
|
| コンテスト | |
| ユーザー |
noisy_noimin
|
| 提出日時 | 2019-12-22 20:47:50 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 11 ms / 3,000 ms |
| コード長 | 1,324 bytes |
| コンパイル時間 | 1,012 ms |
| コンパイル使用メモリ | 115,264 KB |
| 最終ジャッジ日時 | 2025-01-08 13:51:56 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 35 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <numeric>
#include <bitset>
#include <functional>
using namespace std;
using ll = long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
{ 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};
int check(int n, int *a, int i) {
int s = 0;
int cnt = 0;
for(int j=0;j<n;++j) {
if(s == i) {
s = 0;
++cnt;
}
if(s < i) {
s += a[j];
} else {
return 0;
}
}
if(s == i) return cnt+1;
return 0;
}
int main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
int n;
cin >> n;
int a[n], s = 0;
for(int i=0;i<n;++i) {
cin >> a[i];
s += a[i];
}
int ans = 0, cnt;
for(int i=1;i<=int(sqrt(s))+1;++i) {
if(s % i != 0) continue;
cnt = check(n, a, i);
ans = max(cnt, ans);
cnt = check(n, a, s/i);
ans = max(cnt, ans);
}
cout << ans << endl;
}
noisy_noimin