CCF 201909-2 小明种苹果(续)
2024-09-08 19:19:36
#include <iostream>
#include <bits/stdc++.h>
#include <string> using namespace std; typedef struct
{
int end;
bool isDrop;
}Tree; vector<Tree> tree; int main()
{
int n,m;
cin>>n;
while(n--)
{
cin>>m;
Tree temp;
temp.isDrop=false;
for(int i=0;i<m;i++)
{
int tempp;
cin>>tempp;
if(i==0)
{
// temp.base=tempp;
temp.end=tempp;
continue;
}
if(tempp<=0)
{
//temp.subtract.push_back(tempp);
temp.end+=tempp;
}
else
{
if(temp.end!=tempp)
{
temp.isDrop=true;
temp.end=tempp;
}
}
}
tree.push_back(temp);
}
int t=0,d=0,e=0;
for(int i=0;i<tree.size();i++)
{
t+=tree[i].end;
if(tree[i].isDrop)
d++;
if(i==0&&tree[0].isDrop&&tree[1].isDrop&&tree[tree.size()-1].isDrop)
e++;
else if((i==tree.size()-1)&&tree[0].isDrop&&tree[tree.size()-2].isDrop&&tree[tree.size()-1].isDrop)
e++;
else
{
if(tree[i-1].isDrop&&tree[i].isDrop&&tree[i+1].isDrop)
e++;
}
}
cout<<t<<" "<<d<<" "<<e<<endl;
} /*
4
4 74 -7 -12 -5
5 73 -8 -6 59 -4
5 76 -5 -10 60 -2
5 80 -6 -15 59 0
*/
最新文章
- half extents
- 微冷的雨之Java中的多线程初理解(一)
- 【poj2459】 Feed Accounting
- javascript设置网页刷新或者重新加载后滚动条的位置不变
- LightOj1137 - Expanding Rods(二分+数学)
- mvc annotation-driven作用
- [学习笔记]--Jfinal 表单提交附件
- 【贪心】【TOJ4107】【A simple problem】
- 突然兴起复习一下Swift3.0
- 关于UIView用户交互相关的属性和方法
- Android上的Badge,快速实现给应用添加角标
- Java多线程——中断机制
- 清北学堂part1
- 我的C++ 学习心得
- QuickStart系列:docker部署之redis
- WPF背景透明内嵌WebBrowser不显示问题,即AllowsTransparency = true 和 Webbrowser 等控件显示冲突
- 怎么给kibana加上权限?
- shell编程中用户输入处理(shell 04)
- sc";
- 【SSH】——spring的控制反转和依赖注入
热门文章
- 【已解决】SQL2012启动时报错:cannot find one or more cpmponents
- 让你VS Code的通过插件扩展,拥有了三头六臂
- 学习Java Day16
- G - 逆序对的数量
- 微信小程序【关于地址信息的接入以及自动选择当前位置】
- 三元运算符整体执行情况:Object obj = true? Integer.valueOf(1): Double.valueOf(2.0);
- 免杀之:C# XOR Shellcode
- SQL 注入之一:Mysql 数据库(搞懂这篇就够了)
- [专题总结]Gridea快速免费搭建个人博客
- CF825F - String Compression