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;
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int l, r; cin >> l >> r;
vector<pair<int, int>>seg;
for(int i = 1; i <= r; i++){
int left = 0, right = l;
int x; cin >> x;
vector<int>v(x);
for(int j = 0; j < x; j++){
cin >> v[j];
left += v[j];
}
left -= v.back();
for(int j = x - 1; j >= 0; j--){
int l1 = left, r1 = left + v[j];
int l2 = right - v[j], r2 = right;
if(max(l1, l2) < min(r1, r2)){
seg.emplace_back(max(l1, l2), min(r1, r2));
}
if(j) left -= v[j - 1];
right -= v[j];
}
}
sort(seg.begin(), seg.end());
int ans = 0;
int left = -1, right = -1;
for(int i = 0; i < seg.size(); i++){
if(right < seg[i].first){
ans += (right - left);
left = seg[i].first;
}
right = max(right, seg[i].second);
}
ans += (right - left);
cout << ans << '\n';
return 0;
}
Compilation message (stderr)
lasers.cpp: In function 'int main()':
lasers.cpp:36:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
36 | for(int i = 0; i < seg.size(); i++){
| ~~^~~~~~~~~~~~
# | 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... |