AcWing 3278. 小明种苹果(续)
原题链接
简单
作者:
Value
,
2021-04-09 18:13:28
,
所有人可见
,
阅读 332
#include <iostream>
using namespace std;
const int N = 1010;
typedef long long ll;
bool flag[N];
int n;
int main(){
cin >> n;
ll sum = 0;
for(int i = 0; i < n; i ++ ){
int T; cin >> T;
int k; cin >> k;
T -- ;
while(T -- ){
int a; cin >> a;
if(a <= 0) k += a;
else if(k != a) flag[i] = true, k = a;
}
sum += k;
}
ll cnt = 0, e = 0;
for(int i = 0; i < n; i ++ ){
cnt += flag[i];
e += flag[i] && flag[(i + 1) % n] && flag[(i + 2) % n];
}
cout << sum << ' ' << cnt << ' ' << e << endl;
return 0;
}