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;
const int N = 1e6 + 5;
int dp [N];
bool is_invalid [N];
int main () {
ios::sync_with_stdio(0);
cin.tie(0);
int l, r, res = 0;
cin >> l >> r;
memset (dp, 0, sizeof(dp));
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;
for (int i = 0; i < qts; i++) {
++dp[max (mn, cur)];
--dp[l - s - 1 + 1];
mn = max (mn, l - s);
cur += arr[i];
s -= arr[i];
}
++dp[max (mn, cur)];
--dp[l - s - 1 + 1];
}
int x = 0;
for (int i = 0; i < l; i++) {
x += dp[i];
if (x != r) ++res;
}
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... |