제출 #1249086

#제출 시각아이디문제언어결과실행 시간메모리
1249086GeforgsLasers (NOI19_lasers)C++20
63 / 100
89 ms15176 KiB
#include <iostream> #include <iomanip> #include <vector> #include <cmath> #include <algorithm> #include <set> #include <queue> #include <map> #include <stack> #include <bitset> #include <string> #include <cstring> #include <iterator> #include <random> #define ll long long #define ld long double #define inf (ll)(2*1e18) #define sort(a) sort(a.begin(), a.end()) #define reverse(a) reverse(a.begin(), a.end()) #define pb push_back #define endl "\n" using namespace std; void solve(){ ll n, q, i, j, k, l, r, x, y, cnt=0; cin>>n>>q; vector<ll> a(n+1, 0); for(i=0;i<q;++i){ cin>>k; vector<ll> b(k); vector<ll> c(k); vector<ll> d(k); for(j=0;j<k;++j){ cin>>b[j]; } for(j=1;j<k;++j){ c[j] = c[j-1] + b[j-1]; } for(j=k-2;j>=0;--j){ d[j] = d[j+1] + b[j+1]; } for(j=0;j<k;++j){ x = n - c[j] - d[j]; y = x - b[j]; if(y < b[j]){ ++a[y + c[j]]; --a[b[j] + c[j]]; } } } cnt += a[0] != 0; for(i=1;i<n;++i){ a[i] += a[i-1]; cnt += a[i] != 0; } cout<<cnt<<endl; } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); srand(time(nullptr)); ll t=1; // cin>>t; for(;t>0;--t){ solve(); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...