結果

問題 No.1535 五七五
ユーザー Nzt3Nzt3
提出日時 2022-10-13 22:28:43
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 51 ms / 2,000 ms
コード長 567 bytes
コンパイル時間 2,061 ms
コンパイル使用メモリ 200,484 KB
実行使用メモリ 4,860 KB
最終ジャッジ日時 2023-09-08 19:16:21
合計ジャッジ時間 5,077 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,504 KB
testcase_04 AC 32 ms
4,860 KB
testcase_05 AC 35 ms
4,852 KB
testcase_06 AC 36 ms
4,788 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 1 ms
4,384 KB
testcase_18 AC 49 ms
4,856 KB
testcase_19 AC 48 ms
4,820 KB
testcase_20 AC 49 ms
4,816 KB
testcase_21 AC 51 ms
4,852 KB
testcase_22 AC 50 ms
4,820 KB
testcase_23 AC 49 ms
4,856 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N,A,B,C;
  cin>>N>>A>>B>>C;
  vector<int>S(N);
  for(int i=0;i<N;i++){
    string T;
    cin>>T;
    S[i]=T.size();
  }
  int ans=0;
  for(int i1=0,i2=0,i3=0,i4=0,a=0,b=0,c=0;i1<N;i1++){
    for(;i2<N&&a<A;i2++){
      b-=S[i2];
      a+=S[i2];
    }
    for(;i3<N&&b<B;i3++){
      c-=S[i3];
      b+=S[i3];
    }
    for(;i4<N&&c<C;i4++){
      c+=S[i4];
    }
    if(a==A&&b==B&&c==C)++ans;
    a-=S[i1];
  }
  cout<<ans<<'\n';
}
0