Submission #242845

#TimeUsernameProblemLanguageResultExecution timeMemory
242845gs18115Lasers (NOI19_lasers)C++14
100 / 100
181 ms13912 KiB
#include<iostream> #include<vector> #include<algorithm> #define ep emplace #define eb emplace_back #define fi first #define se second #define all(x) (x).begin(),(x).end() using namespace std; typedef long long ll; typedef pair<int,int>pi; typedef pair<ll,ll>pl; const int inf=1e9+7; const ll INF=1e18+7; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int l,r; cin>>l>>r; vector<pi>cv; for(int i=0;i<r;i++) { int x; cin>>x; vector<int>v(x); for(int&t:v) cin>>t; int sm=0,csm=0; for(int&t:v) sm+=t; for(int&t:v) { if(l-sm<t) cv.eb(l-sm+csm,1),cv.eb(csm+t,-1); csm+=t; } } sort(all(cv)); int cur=0,csm=0; int ans=0; for(pi&t:cv) { if(csm>0) ans+=t.fi-cur; cur=t.fi; csm+=t.se; } cout<<ans<<endl; 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...