이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0); cin.tie(0);
map<int, int> pref;
int l, r; cin >> l >> r;
for (int i = 0; i < r; i++) {
int x; cin >> x;
vector<int> vals(x);
int sum = 0, pos = 0;
for (int j = 0; j < x; j++) {
cin >> vals[j];
sum += vals[j];
}
for (int j = 0; j < x; j++) {
int len = l - sum - pos + vals[j];
if (vals[j] - (len - vals[j]) > 0) {
pref[l - sum]++;
pref[l - sum + vals[j] - (len - vals[j])]--;
}
sum -= vals[j];
pos += vals[j];
}
}
int cnt = 0, start = 0, ans = 0;
for (auto i : pref) {
cnt += i.second;
if (i.second > 0) {
if (cnt == 1) {
start = i.first;
}
} else {
if (cnt == 0) {
ans += i.first - start;
}
}
}
cout << ans;
}
# | 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... |