-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathp4.cpp
More file actions
35 lines (28 loc) · 645 Bytes
/
Copy pathp4.cpp
File metadata and controls
35 lines (28 loc) · 645 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include<iostream>
#include<vector>
using ll=long long;
using namespace std;
int main(){
int n; cin>>n;
vector<int>a(n),drop(n);
for(int i=0;i<n;i++){
int m; cin>>m>>a[i];
for(int j=1;j<m;j++){
int x; cin>>x;
if(x>0)
drop[i]+=a[i]-x,
a[i]=x;
else
a[i]-=-x;
}
}
ll sum=0,cnt=0,ec=0;
for(int i=0;i<n;i++)
sum+=a[i],
cnt+=drop[i]>0?1:0;
if(n>=3)
for(int i=0;i<n;i++)
ec+=(drop[i] and drop[(i+1)%n] and drop[(i+2)%n])?1:0;
cout<<sum<<' '<<cnt<<' '<<ec<<'\n';
return 0;
}