結果

問題 No.1535 五七五
ユーザー Nzt3
提出日時 2021-06-06 18:24:14
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 151 ms / 2,000 ms
コード長 602 bytes
コンパイル時間 1,686 ms
コンパイル使用メモリ 169,932 KB
実行使用メモリ 7,296 KB
最終ジャッジ日時 2024-11-23 02:49:49
合計ジャッジ時間 3,887 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  int A,B,C;
  cin>>A>>B>>C;
  vector<int>T(N);
  string S;
  for(int i=0;i<N;i++){
    cin>>S;
    T[i]=S.size();
  }
  T.push_back(10000000);
  T.push_back(10000000);
  T.push_back(10000000);
  int ans=0;
  for(int i=0,cnt1=T[0],cnt2=0,cnt3=0,r1=0,r2=0,r3=0;i<N;i++){
    while(cnt1<A){
      cnt1+=T[++r1];
      cnt2-=T[r1];
    }
    while(cnt2<B){
      cnt2+=T[++r2];
      cnt3-=T[r2];
    }
    while(cnt3<C){
      cnt3+=T[++r3];
    }
    if(cnt1==A&&cnt2==B&&cnt3==C)ans++;
    cnt1-=T[i];
  }
  cout<<ans<<endl;
}
0