# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
699087 | 2023-02-15T15:02:39 Z | DennisTran | Lasers (NOI19_lasers) | C++17 | 32 ms | 7732 KB |
#pragma GCC optimize("O2") #pragma GCC target("avx,avx2,fma") #include <bits/stdc++.h> #define FOR(i, a, b) for (int i = (a); i <= (b); i++) #define FOD(i, a, b) for (int i = (a); i >= (b); i--) #define REP(i, n) for (int i = 0; i < (n); i++) #define ALL(x) (x).begin(), (x).end() #define TIME (1.0 * clock() / CLOCKS_PER_SEC) #define file(name) if (fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); } #define ii pair <int, int> #define fi first #define se second using namespace std; const int MAXN = 5e5 + 5; int L, R, a[MAXN], sum[MAXN]; vector <ii> ans; void solve(void) { cin >> L >> R; FOR(i, 1, R) { int n; cin >> n; FOR(i, 1, n) cin >> a[i], sum[i] = sum[i - 1] + a[i]; vector <ii> lines; FOR(i, 0, n) { int l = sum[i] + 1; int r = L - sum[n] + sum[i]; if (r >= l) lines.emplace_back(l, r); } vector <ii> new_lines; new_lines.emplace_back(-1, -1); for (auto x : lines) if (x.fi <= new_lines.back().se) new_lines.back().se = x.se; else new_lines.emplace_back(x); new_lines.emplace_back(L + 1, L + 1); REP(i, (int) new_lines.size() - 1) { int l = new_lines[i].se + 1, r = new_lines[i + 1].fi - 1; if (r >= l && l > 0) ans.emplace_back(l, r); } } vector <ii> new_ans; sort(ALL(ans)); for (auto x : ans) if (new_ans.size() && x.fi <= new_ans.back().se) new_ans.back().se = x.se; else new_ans.emplace_back(x); int ans = 0; for (auto x : new_ans) ans += x.se - x.fi + 1; cout << ans; } signed main(void) { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); file("LASERS"); //int T; cin >> T; while (T--) solve(); cerr << "Time elapsed: " << TIME << " s.\n"; return (0 ^ 0); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Incorrect | 1 ms | 340 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Incorrect | 1 ms | 340 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 32 ms | 7732 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 340 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 32 ms | 7732 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Incorrect | 1 ms | 340 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |