#include <bits/stdc++.h>
using namespace std;
#define pii pair<ll,ll>
#define REP(i,x,y) for(ll i=x;i<=y;i++)
#define freeopen freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
#define mod 998244353
#define pb push_back
#define mk make_pair
#define ll long long
#define foor(x,vec) for(auto x:vec ){cout<<x<<" ";}
#define fi first
#define se second
#define MAXN 500069
#define lld long double
#define cha ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ffl fflush(stdout)
#define sst string
#define pii pair<ll,ll>
ll mvx[]={0,0,-1,1};
ll mvy[]={1,-1,0,0};
ll n,q;
ll k[MAXN];
vector<ll> b[MAXN];
ll vis[MAXN];
void solve(){
cin>>n>>q;
REP(i,0,q-1){
cin>>k[i];
REP(j,0,k[i]-1){
ll x;
cin>>x;
b[i].pb(x);
}
}
ll ans=0;
REP(i,0,q-1){
ll mx=0;
ll l=0;
REP(j,0,k[i]-1){
mx=max(mx,b[i][j]);
}
ans+=(n-2*(n-mx));
}
ans=max(ans,(ll)0);
cout<<ans<<endl;
}
int main(){
cha
ll tc=1;
// cin>>tc;
while(tc--){
solve();
}
}
Compilation message
lasers.cpp: In function 'void solve()':
lasers.cpp:39:12: warning: unused variable 'l' [-Wunused-variable]
39 | ll l=0;
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
13660 KB |
Output is correct |
2 |
Correct |
5 ms |
13660 KB |
Output is correct |
3 |
Correct |
4 ms |
13660 KB |
Output is correct |
4 |
Correct |
4 ms |
13660 KB |
Output is correct |
5 |
Correct |
4 ms |
13744 KB |
Output is correct |
6 |
Correct |
4 ms |
13660 KB |
Output is correct |
7 |
Correct |
4 ms |
13660 KB |
Output is correct |
8 |
Correct |
4 ms |
13656 KB |
Output is correct |
9 |
Correct |
4 ms |
13656 KB |
Output is correct |
10 |
Correct |
6 ms |
13660 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
13660 KB |
Output is correct |
2 |
Correct |
5 ms |
13660 KB |
Output is correct |
3 |
Correct |
4 ms |
13660 KB |
Output is correct |
4 |
Correct |
4 ms |
13660 KB |
Output is correct |
5 |
Correct |
4 ms |
13744 KB |
Output is correct |
6 |
Correct |
4 ms |
13660 KB |
Output is correct |
7 |
Correct |
4 ms |
13660 KB |
Output is correct |
8 |
Correct |
4 ms |
13656 KB |
Output is correct |
9 |
Correct |
4 ms |
13656 KB |
Output is correct |
10 |
Correct |
6 ms |
13660 KB |
Output is correct |
11 |
Incorrect |
5 ms |
13912 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
18 ms |
18132 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
13660 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
18 ms |
18132 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
13660 KB |
Output is correct |
2 |
Correct |
5 ms |
13660 KB |
Output is correct |
3 |
Correct |
4 ms |
13660 KB |
Output is correct |
4 |
Correct |
4 ms |
13660 KB |
Output is correct |
5 |
Correct |
4 ms |
13744 KB |
Output is correct |
6 |
Correct |
4 ms |
13660 KB |
Output is correct |
7 |
Correct |
4 ms |
13660 KB |
Output is correct |
8 |
Correct |
4 ms |
13656 KB |
Output is correct |
9 |
Correct |
4 ms |
13656 KB |
Output is correct |
10 |
Correct |
6 ms |
13660 KB |
Output is correct |
11 |
Incorrect |
5 ms |
13912 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |