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;
}
相关推荐
穿条秋裤到处跑几秒前
每日一道leetcode(2026.03.30):判断通过操作能否让字符串相等 II
算法·leetcode
Q741_1471 分钟前
每日一题 力扣 2840. 判断通过操作能否让字符串相等 II 力扣 2839. 判断通过操作能否让字符串相等 I 找规律 字符串 C++ 题解
c++·算法·leetcode·力扣·数组·找规律
xu_wenming6 分钟前
在 TinyML 场景下,如何将模型从 FP32 量化为 INT8?
arm开发·算法·iot
kyle~7 分钟前
ROS2 ---- TF2坐标变换(1.动态、静态发布,2.缓存,3.监听)
c++·机器人·ros2
csdn_aspnet9 分钟前
C++ 求n边凸多边形的对角线数量(Find number of diagonals in n sided convex polygon)
开发语言·c++·算法
wsoz11 分钟前
快速从C过渡到C++
c语言·开发语言·c++
深邃-21 分钟前
字符函数和字符串函数(1)
c语言·开发语言·数据结构·c++·算法·html5
初中就开始混世的大魔王21 分钟前
3.1 DDS 层-Core
开发语言·c++·网络协议·tcp/ip·信息与通信
我真不是小鱼22 分钟前
cpp刷题打卡记录24——路径总和 & 路径总和II
数据结构·c++·算法·leetcode
菜鸟小九27 分钟前
JVM垃圾回收
java·jvm·算法