#include<iostream>usingnamespace std;intmain(){
int n, m, sum =0, num =0, max =1;scanf("%d%d",&n,&m);//the total number of trees or Roundsfor(int i =1; i <= n; i++){
int t , k, f =0;scanf("%d",&t);//The total number of apples at the beginningfor(int j =0;j < m;j++){
scanf("%d",&k);
f += k;//total number of fruits picked}if(f < max){
max = f;//maximum fruit picking
num = i;//apple tree number}
sum += t + f;}printf("%d %d %d", sum, num,-max);return0;}
3 3
73 -8 -6 -4
76 -5 -10 -8
80 -6 -15 0
167 2 23
2 2
10 -3 -1
15 -4 0
17 1 4
2.小明种苹果(续)
#include<iostream>#include<algorithm>usingnamespace std;constint MAXN=1002;intmain(){
int n, m, t =0, d =0, e =0;//whether or not apples to fallbool f[MAXN]={
false};
cin >> n;//Number of treesfor(int i =0; i < n;++i){
int sum;
cin >> m >> sum;//Initial number of appleswhile(--m){
int k;
cin >> k;if(k <=0){
//Picking fruit
sum += k;}else{
//k>0,Now number of applesif(sum > k)//There are apples falling
f[i]=true;//sign trees
sum = k;}}
t += sum;//Store the total number of apples}//Calculate number of trees which apples to fall
d =count(f, f + n,true);//Calculate number of three trees in a row which apples to fallfor(int i =0; i < n;++i){
//trees end-to-endif(f[i]&& f[(i +1)% n]&& f[(i +2)% n])++e;}
cout << t <<" "<< d <<" "<< e;return0;}
1. 小明种苹果#include <iostream>using namespace std;int main(){ int n, m, sum = 0, num = 0, max = 1; scanf("%d%d",&n, &m);//the total number of trees or Rounds for(int i = 1; i <= n; i++){ int t , k, f = 0;