# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1072685 | _rain_ | Lasers (NOI19_lasers) | C++14 | 126 ms | 13780 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>
using namespace std;
#define ll long long
#define fixbug false
void SETIO(string name = ""){
if (name=="") return;
freopen((name+".inp").c_str(),"r",stdin);
// freopen((name+".out").c_str(),"w",stdout);
return;
}
int numrow , L;
#define fi first
#define se second
int main(){
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
SETIO("");
cin >> L >> numrow;
vector<pair<int,int>> ev;
for (int i = 1; i <= numrow; ++i){
int x; cin >> x;
vector<int> a(x+2,0) , pre(x+2,0);
for (int j = 1; j <= x; ++j) {
cin >> a[j];
pre[j] = pre[j - 1] + a[j];
}
for (int j = 1; j <= x; ++j){
int jump = a[j];
int l = pre[j - 1] + 1 , r = L - (pre[x] - pre[j]);
if (l + jump - 1 < r - jump + 1) continue;
ev.push_back({min(L+1,l + jump) , -1});
ev.push_back({max(1,r - jump + 1) , 1});
if (fixbug){
cout << "FIXBUG\n";
cout << i << ' ' << j << ' ' << l << ' ' << r << '\n';
}
}
}
sort(ev.begin(),ev.end());
int leftmost = -1 , sum = 0 , ans= 0;
for (int i = 0; i < ev.size(); ++i){
if (leftmost == -1) leftmost = ev[i].fi;
sum += ev[i].se;
if (sum==0){
if (fixbug){
cout << "DEBUG\n";
cout << ev[i].fi << ' ' << ev[i].se << '\n';
}
ans += ev[i].fi - leftmost ;
leftmost = -1;
}
}
cout << ans;
}
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... |