Advertisement
Patrickmeme

Seism-80p

Feb 5th, 2023
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.22 KB | None | 0 0
  1. #include <fstream>
  2.  
  3. using namespace std;
  4. ifstream cin("seism.in");
  5. ofstream cout("seism.out");
  6. int v[100000];
  7. int main()
  8. {
  9.     int cer,n,i,stare,max1,cnt,cntd;
  10.     cin>>cer>>n;
  11.     ///citire
  12.     for(i=0;i<n;i++)
  13.         cin>>v[i];
  14.  
  15.     stare=max1=cnt=0;
  16.     if(cer==1){
  17.         for(i=1;i<n-1;i++){
  18.             if(stare==0){
  19.                 if(v[i]==0 && v[i-1]==0 && v[i+1]==1)
  20.                     stare=1;
  21.             }else{
  22.                 if(v[i]==1){
  23.                     cnt++;
  24.                 }else{
  25.                     if(i+1<n && v[i+1]==0){
  26.                         if(cnt>max1)
  27.                             max1=cnt;
  28.                     }
  29.                     cnt=stare=0;
  30.                 }
  31.             }
  32.         }
  33.         cout<<max1;
  34.     }else if(cer==2){
  35.         cntd=0;
  36.         for(i=1;i<n-1;i++){
  37.             if(stare==0){
  38.                  if(v[i]==0 && v[i-1]==0 && v[i+1]==1)
  39.                     stare=1;
  40.             }else{
  41.                 if(v[i]==1){
  42.                     cnt++;
  43.                 }else{
  44.                     if(v[i+1]==0)
  45.                             cntd++;
  46.                     cnt=stare=0;
  47.                 }
  48.             }
  49.         }
  50.         cout<<cntd;
  51.     }
  52.     return 0;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement