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::sync_with_stdio(0);
cin.tie(0);
int l, r, res = 0;
cin >> l >> r;
map<int, int> eventos;
for (int T = 0; T < r; T++) {
int qts;
cin >> qts;
int s = 0;
vector<int> arr (qts);
for (int i = 0; i < qts; i++) {
cin >> arr[i];
s += arr[i];
}
int cur = 0;
int mn = 0;
int st, et;
for (int i = 0; i < qts; i++) {
st = max (mn, cur);
et = l - s - 1;
//cout << st << ' ' << et << '\n';
eventos[st]++;
eventos[et + 1]--;
mn = max (mn, l - s);
cur += arr[i];
s -= arr[i];
}
st = max (mn, cur);
et = l - s - 1;
//cout << st << ' ' << et << '\n';
eventos[st]++;
eventos[et + 1]--;
}
eventos[l - 1] += 0;
int cur = 0;
int where_am_i = 0;
for (auto to : eventos) {
int where = to.first;
int d = to.second;
if (cur < r) {
res += (where - where_am_i);
}
cur += d;
where_am_i = where;
}
cout << res << '\n';
return 0;
}
# | 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... |