Submission #743075

#TimeUsernameProblemLanguageResultExecution timeMemory
743075Sainen420Lasers (NOI19_lasers)C++17
100 / 100
202 ms9952 KiB
#include <bits/stdc++.h> using namespace std; using pi = pair<int,int>; int l,r,in,n,ans=0; int qs[500005]={}; vector<pi> ep; int main() { cin.tie(nullptr)->sync_with_stdio(false); cin >> l >> r; qs[0]=0; for(int i=0;i<r;i++){ cin >> n; for(int j=1;j<=n;j++){ cin >> qs[j]; qs[j]+=qs[j-1]; } //qs[n+1]=qs[n]; for(int j=1;j<=n;j++){ //gen ep int sp=qs[j-1],sn=qs[n]-qs[j],val=qs[j]-qs[j-1]; int L=val,M=l-sn-sp; //cout << '=' << L << ' ' << M << endl; if(M-L+1 > L)continue; ep.push_back({M-L+1+sp,1}); ep.push_back({L+1+sp,-1}); } } sort(ep.begin(),ep.end()); ep.push_back({l,-9999}); int block=0; for(int i=0,j=ep.size()-1;i<j;i++){ auto[indx,v]=ep[i]; //cout << indx << ' ' << v << ' ' << endl; block+=v; if(block>=1 && (ep[i+1]).first > indx){ ans+=((ep[i+1]).first - indx); } } cout << ans; return 0; } /* 11 3 2 2 3 1 7 2 4 1 */
#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...