🎆音乐分享 (点击链接可以播放哦)
Dashboard – Codeforces Round 857 (Div. 2) – Codeforces
根据我的经验,cf的A题,有时候看给出的样例就能a出来,那么a题就不记录了😉
下面是B题
这种长文字的题,建议先用翻译工具翻译(虽然有可能不准确),了解个大概,然后再处理细节
这样可以节约时间
#include<iostream>
using namespace std;
#define ll long long
const int N=10010;
int a[N];
int main()
{
int t;
cin>>t;
while(t--)
{
ll n;
ll ans = 0, pigs = 0, cages = 0;
cin >> n;
for(int i=0;i<n;i++)
{
cin>>a[i];
if (a[i] == 1)
{
pigs++;
cages++;
}
else
{
if (pigs != 0)//关键点
{
cages = pigs / 2 + 1;
}
}
ans = max(ans, cages);
}
cout << ans << endl;
}
}
Code over!
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
文章由极客之音整理,本文链接:https://www.bmabk.com/index.php/post/131363.html