# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
830306 | exodus_ | Lasers (NOI19_lasers) | C++14 | 256 ms | 9984 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |