wojiaocbj

cbj

Mar 12th, 2022
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.76 KB | None | 0 0
  1. /*
  2.  Author: 曹北健(37509)
  3.  Result: AC
  4. */
  5.  
  6. #include <stdio.h>
  7. #include <stdlib.h>
  8. #include <math.h>
  9. #include <string.h>
  10. #include <ctype.h>
  11. #pragma warning(disable:4996)
  12. int main(){
  13.     int n, i, j, a[128] = { 0 }, flag = 0, countof1 = 0, ser = 0, sermax = 0;
  14.     scanf("%d", &n);
  15.     for(i = 0;i < n;i++){
  16.         scanf("%d", a + i);
  17.     }
  18.     if(n < 9){
  19.         puts("-1");
  20.     }
  21.     else{
  22.         for(i = 0;i < n - 9;i++){
  23.             countof1 = 0;
  24.             ser = 0;
  25.             sermax = 0;
  26.             for(j = 0;j < 9;j++){
  27.                 if(a[i + j] == 1){
  28.                     countof1++;
  29.                     ser++;
  30.                     if(sermax < ser){
  31.                         sermax = ser;
  32.                     }
  33.                 }
  34.                 else{
  35.                     ser = 0;
  36.                 }
  37.             }
  38.             if(sermax == 5 && countof1 == 7){
  39.                 flag = i + 9;
  40.                 break;
  41.             }
  42.         }
  43.         printf("%d\n", flag > 0 ? flag : -1);
  44.     }
  45.     return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment