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;
}
相关推荐
潼心1412o4 分钟前
C++初阶(长期更新)第9讲:string(上)
开发语言·c++
朝朝辞暮i16 分钟前
C++ 第 39 章: 阶段性总复习——类、对象、构造、继承、this、指针与智能指针
开发语言·c++·算法·ros2
wuminyu29 分钟前
Virtual Thread重投递至ForkJoinPool任务队列过程解析
java·linux·c语言·jvm·c++
垆边人似月.29 分钟前
华为题:污染水域
算法
All for pursuit.1 小时前
【回溯-6】79.单词搜索
数据结构·c++·算法·leetcode
ZhangJun951 小时前
Mobike 共享单车分析项目
人工智能·python·算法·kmeans·聚类·knn
Navigator_Z1 小时前
LeetCode //C - 1281. Subtract the Product and Sum of Digits of an Integer
c语言·算法·leetcode
薛定e的猫咪1 小时前
(AISTATS 2023)BaCaDI 逐章阅读
人工智能·深度学习·算法·机器学习
Benny_Tang1 小时前
AT_arc180_d [ARC180D] Division into 3 题解
数据结构·c++·算法
殷色玫瑰2 小时前
C++ STL:stack、queue、priority_queue 与容器适配器详解
java·开发语言·数据结构·c++·算法·visualstudio