首页 > 移动平台 > 详细

CCF 201909-2 小明种苹果(续)

时间:2021-02-06 13:29:38      阅读:17      评论:0      收藏:0      [点我收藏+]
#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
*/

 

CCF 201909-2 小明种苹果(续)

原文:https://www.cnblogs.com/-Asurada-/p/14381191.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!