Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Author: 曹北健(37509)
- Result: AC
- */
- #include <stdio.h>
- #include <stdlib.h>
- #include <math.h>
- #include <string.h>
- #include <ctype.h>
- #pragma warning(disable:4996)
- int main(){
- int n, i, j, a[128] = { 0 }, flag = 0, countof1 = 0, ser = 0, sermax = 0;
- scanf("%d", &n);
- for(i = 0;i < n;i++){
- scanf("%d", a + i);
- }
- if(n < 9){
- puts("-1");
- }
- else{
- for(i = 0;i < n - 9;i++){
- countof1 = 0;
- ser = 0;
- sermax = 0;
- for(j = 0;j < 9;j++){
- if(a[i + j] == 1){
- countof1++;
- ser++;
- if(sermax < ser){
- sermax = ser;
- }
- }
- else{
- ser = 0;
- }
- }
- if(sermax == 5 && countof1 == 7){
- flag = i + 9;
- break;
- }
- }
- printf("%d\n", flag > 0 ? flag : -1);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment