Submission #830306

#TimeUsernameProblemLanguageResultExecution timeMemory
830306exodus_Lasers (NOI19_lasers)C++14
100 / 100
256 ms9984 KiB
#include<bits/stdc++.h> #define se second #define fi first using namespace std; const int nmax = 5*1e5+5; int lenwall[nmax]; vector<pair<int,int>>blck; int main() { int L,R,X; int maxlen = 0; cin >> L >> R; for(int i=1; i<=R; i++) { cin >> X; int le=0; int ri=L; for(int j=1; j<=X; j++) { cin >> lenwall[j]; le+=lenwall[j]; } le-=lenwall[X]; for(int k=X; k>=1; k--) { int l=le; int r=le+lenwall[k]; int lt=ri-lenwall[k]; int rt=ri; if(max(l,lt) < min(r,rt)) blck.push_back({max(l,lt), min(r,rt)}); if(k!=1) le-=lenwall[k-1]; ri-=lenwall[k]; } } sort(blck.begin(), blck.end()); int ans=0; int right=0, left=0; for(int i=0; i<blck.size(); i++) { if(right<blck[i].fi) { ans+=(right-left); left = blck[i].fi; right = blck[i].fi; } right = max(right, blck[i].se); } ans+=(right-left); cout << ans << endl; return 0; }

Compilation message (stderr)

lasers.cpp: In function 'int main()':
lasers.cpp:34:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |     for(int i=0; i<blck.size(); i++) {
      |                  ~^~~~~~~~~~~~
lasers.cpp:10:9: warning: unused variable 'maxlen' [-Wunused-variable]
   10 |     int maxlen = 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...