# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1102321 | 2024-10-18T02:17:51 Z | thangdz2k7 | Inspections (NOI23_inspections) | C++17 | 290 ms | 34152 KB |
// author : thembululquaUwU // 3.9.2024 #include <bits/stdc++.h> #define pb push_back #define fi first #define se second #define endl '\n' using namespace std; using ll = long long; using ii = pair <int, int>; using vi = vector <int>; const int N = 2e5 + 5; const int mod = 1e9 + 7; void maxl(auto &a, auto b) {a = max(a, b);} void minl(auto &a, auto b) {a = min(a, b);} int n, m, q, lo; set <ii> s; long long last[N]; vector <pair <long long, int>> e; void add(long long u, int val){ e.emplace_back(u, val + q); //cout << lo << ' ' << u << ' ' << val << endl; } void solve(){ cin >> n >> m >> q; s.insert({1, n}); long long timer = 0; for (lo = 1; lo <= m; ++ lo){ int l, r; cin >> l >> r; for (auto it = s.lower_bound({l, l}); it != s.end();){ auto [u, v] = *it; if (u > r) break; it = s.erase(it); if (v <= r){ if (last[u]) add(timer + u - l - last[u], v - u + 1); } else { if (last[u]) add(timer + u - l - last[u], r - u + 1); s.insert({r + 1, v}); if (last[u]) last[r + 1] = last[u] + (r - u + 1); break; } } last[l] = timer + 1; s.insert({l, r}); if (l > 1){ auto [u, v] = *(--s.lower_bound({l, l})); if (v >= l && v <= r){ if (last[u]) add(timer - (last[u] + l - u), v - l + 1); s.erase({u, v}); s.insert({u, l - 1}); } else if (v >= l){ if (last[u]) add(timer - (last[u] + l - u), r - l + 1); s.erase({u, v}); s.insert({u, l - 1}); s.insert({r + 1, v}); if (last[u]) last[r + 1] = last[u] + (r - u + 1); } } timer += (r - l + 1); } for (int i = 0; i < q; ++ i){ ll s; cin >> s; e.emplace_back(s, i); } vector <long long> ans(q); sort(e.begin(), e.end()); reverse(e.begin(), e.end()); long long cur = 0; for (auto [d, id] : e){ if (id > q) cur += id - q; else ans[id] = cur; } for (long long &f : ans) cout << f << ' '; } int main(){ if (fopen("pqh.inp", "r")){ freopen("pqh.inp", "r", stdin); freopen("pqh.out", "w", stdout); } ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t = 1; // cin >> t; while (t --) solve(); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 468 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 1 ms | 340 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 1 ms | 340 KB | Output is correct |
10 | Correct | 1 ms | 340 KB | Output is correct |
11 | Correct | 1 ms | 340 KB | Output is correct |
12 | Correct | 1 ms | 340 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 468 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 1 ms | 340 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 1 ms | 340 KB | Output is correct |
10 | Correct | 1 ms | 340 KB | Output is correct |
11 | Correct | 1 ms | 340 KB | Output is correct |
12 | Correct | 1 ms | 340 KB | Output is correct |
13 | Correct | 43 ms | 8012 KB | Output is correct |
14 | Correct | 41 ms | 7872 KB | Output is correct |
15 | Correct | 46 ms | 7884 KB | Output is correct |
16 | Correct | 41 ms | 8120 KB | Output is correct |
17 | Correct | 40 ms | 7884 KB | Output is correct |
18 | Correct | 40 ms | 7896 KB | Output is correct |
19 | Correct | 41 ms | 8124 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 38 ms | 7884 KB | Output is correct |
4 | Correct | 43 ms | 10200 KB | Output is correct |
5 | Correct | 111 ms | 23224 KB | Output is correct |
6 | Correct | 123 ms | 23876 KB | Output is correct |
7 | Correct | 85 ms | 16052 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 1 ms | 472 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 468 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 1 ms | 340 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 1 ms | 340 KB | Output is correct |
10 | Correct | 1 ms | 340 KB | Output is correct |
11 | Correct | 1 ms | 340 KB | Output is correct |
12 | Correct | 1 ms | 340 KB | Output is correct |
13 | Correct | 43 ms | 8012 KB | Output is correct |
14 | Correct | 41 ms | 7872 KB | Output is correct |
15 | Correct | 46 ms | 7884 KB | Output is correct |
16 | Correct | 41 ms | 8120 KB | Output is correct |
17 | Correct | 40 ms | 7884 KB | Output is correct |
18 | Correct | 40 ms | 7896 KB | Output is correct |
19 | Correct | 41 ms | 8124 KB | Output is correct |
20 | Correct | 41 ms | 10692 KB | Output is correct |
21 | Correct | 40 ms | 9936 KB | Output is correct |
22 | Correct | 40 ms | 10684 KB | Output is correct |
23 | Correct | 42 ms | 8444 KB | Output is correct |
24 | Correct | 40 ms | 9692 KB | Output is correct |
25 | Correct | 42 ms | 10172 KB | Output is correct |
26 | Correct | 42 ms | 10432 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 468 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 1 ms | 340 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 1 ms | 340 KB | Output is correct |
10 | Correct | 1 ms | 340 KB | Output is correct |
11 | Correct | 1 ms | 340 KB | Output is correct |
12 | Correct | 1 ms | 340 KB | Output is correct |
13 | Correct | 43 ms | 8012 KB | Output is correct |
14 | Correct | 41 ms | 7872 KB | Output is correct |
15 | Correct | 46 ms | 7884 KB | Output is correct |
16 | Correct | 41 ms | 8120 KB | Output is correct |
17 | Correct | 40 ms | 7884 KB | Output is correct |
18 | Correct | 40 ms | 7896 KB | Output is correct |
19 | Correct | 41 ms | 8124 KB | Output is correct |
20 | Correct | 1 ms | 340 KB | Output is correct |
21 | Correct | 1 ms | 340 KB | Output is correct |
22 | Correct | 38 ms | 7884 KB | Output is correct |
23 | Correct | 43 ms | 10200 KB | Output is correct |
24 | Correct | 111 ms | 23224 KB | Output is correct |
25 | Correct | 123 ms | 23876 KB | Output is correct |
26 | Correct | 85 ms | 16052 KB | Output is correct |
27 | Correct | 1 ms | 340 KB | Output is correct |
28 | Correct | 1 ms | 472 KB | Output is correct |
29 | Correct | 41 ms | 10692 KB | Output is correct |
30 | Correct | 40 ms | 9936 KB | Output is correct |
31 | Correct | 40 ms | 10684 KB | Output is correct |
32 | Correct | 42 ms | 8444 KB | Output is correct |
33 | Correct | 40 ms | 9692 KB | Output is correct |
34 | Correct | 42 ms | 10172 KB | Output is correct |
35 | Correct | 42 ms | 10432 KB | Output is correct |
36 | Correct | 166 ms | 22192 KB | Output is correct |
37 | Correct | 172 ms | 23648 KB | Output is correct |
38 | Correct | 161 ms | 23376 KB | Output is correct |
39 | Correct | 129 ms | 24248 KB | Output is correct |
40 | Correct | 160 ms | 22956 KB | Output is correct |
41 | Correct | 242 ms | 26896 KB | Output is correct |
42 | Correct | 233 ms | 27620 KB | Output is correct |
43 | Correct | 287 ms | 33452 KB | Output is correct |
44 | Correct | 273 ms | 34152 KB | Output is correct |
45 | Correct | 205 ms | 22964 KB | Output is correct |
46 | Correct | 269 ms | 24812 KB | Output is correct |
47 | Correct | 290 ms | 25004 KB | Output is correct |
48 | Correct | 177 ms | 23724 KB | Output is correct |