이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int presum[500005], start[500005], close[500005];
int main() {
int l, r, x, w;
cin >> l >> r;
for (int i = 1; i <= r; i++) {
cin >> x;
for (int j = 1; j <= x; j++) {
cin >> w;
presum[j] = presum[j-1] + w;
}
int gap = l - presum[x];
for (int j = 1; j <= x; j++) {
if (presum[j-1] + gap + 1 <= presum[j]) {
start[presum[j-1] + gap + 1]++;
close[presum[j]]++;
}
}
}
// Line Sweep
int count = 0, save, ans = 0;
for (int i = 1; i <= l; i++) {
// cout << i << " " << start[i] << " " << close[i] << endl;
if (start[i] == 0 and close[i] == 0) continue;
if (count == 0) save = i;
count += start[i];
count -= close[i];
if (count == 0) {
ans += (i-save)+1;
}
}
cout << ans << endl;
}
# | 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... |