結果

問題 No.1535 五七五
ユーザー Nzt3Nzt3
提出日時 2021-06-06 18:24:14
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 143 ms / 2,000 ms
コード長 602 bytes
コンパイル時間 2,526 ms
コンパイル使用メモリ 167,288 KB
実行使用メモリ 8,116 KB
最終ジャッジ日時 2023-08-15 00:35:55
合計ジャッジ時間 4,169 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,384 KB
testcase_04 AC 61 ms
7,664 KB
testcase_05 AC 143 ms
7,144 KB
testcase_06 AC 143 ms
7,664 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,384 KB
testcase_10 AC 2 ms
4,384 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,384 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 2 ms
4,384 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 111 ms
8,116 KB
testcase_19 AC 110 ms
7,180 KB
testcase_20 AC 111 ms
7,256 KB
testcase_21 AC 112 ms
7,292 KB
testcase_22 AC 111 ms
7,716 KB
testcase_23 AC 111 ms
8,116 KB
権限があれば一括ダウンロードができます

ソースコード

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