Submission #237808

#TimeUsernameProblemLanguageResultExecution timeMemory
237808Haunted_CppLasers (NOI19_lasers)C++17
100 / 100
946 ms40952 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...