結果

問題 No.1535 五七五
ユーザー spipipikespipipike
提出日時 2021-06-06 19:04:57
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 150 ms / 2,000 ms
コード長 610 bytes
コンパイル時間 1,763 ms
コンパイル使用メモリ 170,376 KB
実行使用メモリ 5,284 KB
最終ジャッジ日時 2023-08-15 02:07:25
合計ジャッジ時間 4,794 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 67 ms
5,196 KB
testcase_05 AC 149 ms
5,124 KB
testcase_06 AC 150 ms
5,120 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,384 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 1 ms
4,384 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,384 KB
testcase_18 AC 121 ms
5,116 KB
testcase_19 AC 120 ms
5,084 KB
testcase_20 AC 121 ms
5,284 KB
testcase_21 AC 121 ms
5,140 KB
testcase_22 AC 121 ms
5,080 KB
testcase_23 AC 120 ms
5,088 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
	int n;
	cin>>n;
	vector<int> fsf(3);
	rep(i, 3) cin>>fsf[i];
	reverse(fsf.begin(), fsf.end());
	vector<int> sn(n);
	rep(i, n){
		string s;
		cin>>s;
		sn[i]=s.size();
	}

	vector<bool> dp(n+1, 1);
	for(int k : fsf){
		int r=0, c=0;
		rep(i, n){
			for(; r<n && c+sn[r]<=k; r++) c+=sn[r];
			if(c==k) dp[i]=dp[r];
			else dp[i]=0;

			if(i==r) r++;
			else c-=sn[i];
		}
		dp[n]=0;
	}

	int cnt=0;
	rep(i, n) if(dp[i]) cnt++;
	cout<<cnt<<endl;
	return 0;
}
0