CF1829B.Blank Space

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given a binary array aa of nn elements, a binary array is an array consisting only of 00s and 11s.

A blank space is a segment of consecutive elements consisting of only 00s.

Your task is to find the length of the longest blank space.

给你一个长度为 nn 的二进制数组 aa,二进制数组是指仅由 00 和 11 组成的数组。

空白段是指由连续的 00 构成的一段子数组。

你的任务是找出最长空白段的长度。

输入格式

The first line contains a single integer tt (1≤t≤10001 \leq t \leq 1000) — the number of test cases.

The first line of each test case contains a single integer nn (1≤n≤1001 \leq n \leq 100) — the length of the array.

The second line of each test case contains nn space-separated integers aia_i (0≤ai≤10 \leq a_i \leq 1) — the elements of the array.

第一行包含一个整数 tt(1≤t≤10001 \leq t \leq 1000)—— 测试用例的数量。

每个测试用例的第一行包含一个整数 nn(1≤n≤1001 \leq n \leq 100)—— 数组的长度。

每个测试用例的第二行包含 nn 个以空格分隔的整数 aia_i(0≤ai≤10 \leq a_i \leq 1)—— 数组的元素。

输出格式

For each test case, output a single integer — the length of the longest blank space.

对于每个测试用例,输出一个整数——最长空白段的长度。

输入输出样例

  • 输入#1

    5
    5
    1 0 0 1 0
    4
    0 1 1 1
    1
    0
    3
    1 1 1
    9
    1 0 0 0 1 0 0 0 1

    输出#1

    2
    1
    1
    0
    3

输入解题思路,AI测评打分。不知道怎么写?

首页