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

cpp 复制代码
#include<iostream>
using namespace std;

int main(){
    int n,m;
    cin>>n;
    int apple[n];
    int drop[n];
    for(int i=0;i<n;i++){
        cin>>m>>apple[i];
        drop[i]=0;
        for (int j = 0; j < m-1; ++j) {
            int temp;
            cin>>temp;
            if(temp<=0) apple[i]+=temp;
            else {
                if(temp!=apple[i])  {
                    drop[i]=1;
                    apple[i]=temp;
                }
            }
        }
    }

    int sum=0,Applesum=0,dropsum=0;
    for(int i=0;i<n;i++){
        Applesum+=apple[i];
        if(drop[i]==1) dropsum++;
        int pre=i,mid=(i+1)%n,succ=(i+2)%n;
        if(drop[pre]==1&&drop[mid]==1&&drop[succ]==1) {
            sum++;
        }
    }

    cout<<Applesum<<" "<<dropsum<<" "<<sum;
    return 0;
}
相关推荐
再睡一夏就好2 分钟前
【C++闯关笔记】详解多态
c语言·c++·笔记·学习·语法·1024程序员节
断剑zou天涯2 小时前
【算法笔记】暴力递归尝试
java·笔记·算法
油泼辣子多加2 小时前
【实战】自然语言处理--长文本分类(1)DPCNN算法
算法·自然语言处理·分类
I'm a winner3 小时前
基于YOLO算法的医疗应用专题:第一章 计算机视觉与深度学习概述
算法·yolo·计算机视觉
vir023 小时前
P1928 外星密码(dfs)
java·数据结构·算法·深度优先·1024程序员节
喜欢吃燃面3 小时前
数据结构算法题:list
开发语言·c++·学习·算法·1024程序员节
胡萝卜3.03 小时前
C++ list核心接口与实战技巧
数据结构·c++·list·list使用
。TAT。3 小时前
C++ - 多态
开发语言·c++·学习·1024程序员节
寂静山林3 小时前
UVa 12991 Game Rooms
算法·1024程序员节