| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1287367 | hehehe147 | Lasers (NOI19_lasers) | C++20 | 93 ms | 8800 KiB |
#include <bits/stdc++.h>
using namespace std;
int a[500007];
void solve() {
int n, L;
cin >> L >> n;
vector<pair<int, int>> e;
for (int i = 1; i <= n; i++) {
int m;
cin >> m;
int pref = 0, suff = 0, sum = 0;
for (int j = 1; j <= m; j++) {
cin >> a[j];
sum += a[j];
}
for (int j = 1; j <= m; j++) {
suff = L - sum + pref + 1;
pref += a[j];
if (pref >= suff) {
e.push_back({suff, 1});
e.push_back({pref + 1, -1});
}
}
}
e.push_back({L + 1, 0});
sort(e.begin(), e.end());
int ans = 0, cnt = 0;
for (int i = 0; i < e.size(); i++) {
cnt += e[i].second;
if (cnt) {
ans += e[i + 1].first - e[i].first;
}
}
cout << ans << "\n";
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
if (fopen("laser.inp", "r")) {
freopen("laser.inp", "r", stdin);
freopen("laser.out", "w", stdout);
}
solve();
}
Compilation message (stderr)
| # | 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... | ||||
