Submission #477237

#TimeUsernameProblemLanguageResultExecution timeMemory
477237niloyrootLasers (NOI19_lasers)C++14
100 / 100
187 ms45032 KiB
#include <bits/stdc++.h> using namespace std; #define forp(i,a,b) for(int i=a;i<=b;i++) #define ll long long #define newl '\n' void solve(){ ll l,r; cin>>l>>r; vector<ll> R[r+1]; ll x,u,s; ll sum[r+1]; forp(i,1,r){ cin>>x; s=0; forp(j,1,x){ cin>>u; s+=u; R[i].push_back(u); } sum[i]=s; } ll s1,s2; vector<pair<ll,ll>> v; forp(i,1,r){ s1=0; s2=sum[i]; for(auto e:R[i]){ s2-=e; if(l-s1-s2<2*e){ v.push_back({l-(s2+e)+1,s1+e}); } s1+=e; } } sort(v.begin(), v.end()); v.push_back({-1,-1}); ll mx=0,ans=0; forp(i,0,v.size()-1){ if(v[i].first!=v[i+1].first){ if(v[i].first>mx){ ans+=v[i].second-v[i].first+1; mx=v[i].second; } else if(v[i].second>mx){ ans+=(v[i].second-mx); mx=v[i].second; } } } cout<<ans<<newl; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); solve(); }

Compilation message (stderr)

lasers.cpp: In function 'void solve()':
lasers.cpp:3:34: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    3 | #define forp(i,a,b) for(int i=a;i<=b;i++)
......
   36 |     forp(i,0,v.size()-1){
      |          ~~~~~~~~~~~~~~           
lasers.cpp:36:5: note: in expansion of macro 'forp'
   36 |     forp(i,0,v.size()-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...