結果

問題 No.944 煎っぞ!
ユーザー d_seid_sei
提出日時 2019-12-07 09:39:51
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,755 bytes
コンパイル時間 797 ms
コンパイル使用メモリ 97,752 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-08-26 02:20:44
合計ジャッジ時間 8,182 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 7 ms
4,380 KB
testcase_12 AC 3 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 WA -
testcase_15 AC 3 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 8 ms
4,380 KB
testcase_19 AC 7 ms
4,376 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 17 ms
4,376 KB
testcase_28 AC 2 ms
4,384 KB
testcase_29 AC 1 ms
4,380 KB
testcase_30 WA -
testcase_31 AC 13 ms
4,380 KB
testcase_32 AC 14 ms
4,376 KB
testcase_33 AC 14 ms
4,380 KB
testcase_34 AC 15 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	int N;
	cin >> N;
	if (N == 1) {
		cout << 0 << endl;
	}
	else {
		vector<int>A(N);
		rep(i, N) {
			cin >> A[i];
		}
		vector<int>SA(N);
		SA[0] = A[0];
		for (int i = 1; i < N; i++) {
			SA[i] = SA[i - 1] + A[i];
		}
		int ssum = 0;
		int sum = 0;
		int ans = 0;
		int c = 0;
		rep(i, N) {
			ssum = SA[i];
			sum = 0;
			ans = 0;
			c = 0;
			for (int j = i + 1; j < N; j++) {
				if (sum + A[j] <= ssum) {
					sum += A[j];
					if (sum == ssum) {
						sum = 0;
						ans++;
					}
				}
				else {
					c = 1;
					break;
				}
			}
			if (c == 0) {
				cout << ans + 1 << endl;
				return 0;
			}
		}
	}
}


0