# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1117971 | 2024-11-24T14:11:21 Z | blackslex | Inspections (NOI23_inspections) | C++17 | 362 ms | 42212 KB |
#include<bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<ll, ll>; using tp = tuple<ll, ll, ll>; const int N = 2e5 + 5; int n, m, q; int main() { scanf("%d %d %d", &n, &m, &q); vector<pii> c(m); multiset<tp> ms; vector<ll> cnt(m); map<ll, int> mp; for (auto &[x, y]: c) scanf("%d %d", &x, &y); for (int i = 0; i < m; i++) { cnt[i] = c[i].second - c[i].first + 1; if (i) cnt[i] += cnt[i - 1]; } auto get2 = [&] (int idx) { return (idx >= 0 ? cnt[idx] : 0); }; auto getpos = [&] (int val, int idx) { auto [x, y] = c[idx]; ll pos = get2(idx - 1) + val - x + 1; return pos; }; for (int i = 0; i < m; i++) { auto [l, r] = c[i]; auto it = ms.lower_bound(tp(l, 0, 0)); if (it != ms.begin() && get<1>(*prev(it)) >= l) it = prev(it); vector<tp> cc, cc2; while (it != ms.end() && get<0>(*it) <= r) { auto [x, y, z] = *it; cc.emplace_back(*it); ll diff = getpos(x, i) - getpos(x, z); int sz = y - x + 1; if (x < l) sz -= l - x; if (y > r) sz -= y - r; mp[diff] += sz; if (x < l) cc2.emplace_back(x, l - 1, z); if (y > r) cc2.emplace_back(r + 1, y, z); it = next(it); } for (auto &e: cc) ms.erase(ms.find(e)); for (auto &e: cc2) ms.emplace(e); ms.emplace(l, r, i); } vector<ll> cq(q), ans(q); vector<tp> co; for (auto &e: cq) scanf("%d", &e); for (int i = 0; i < q; i++) co.emplace_back(cq[i], 0, i); for (auto &[x, y]: mp) co.emplace_back(x - 1, 1, y); sort(co.rbegin(), co.rend()); ll cans = 0; for (auto &[x, y, z]: co) { if (y) cans += z; else ans[z] = cans; } for (int i = 0; i < q; i++) printf("%lld ", ans[i]); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 336 KB | Output is correct |
2 | Correct | 1 ms | 336 KB | Output is correct |
3 | Correct | 1 ms | 336 KB | Output is correct |
4 | Correct | 1 ms | 336 KB | Output is correct |
5 | Correct | 1 ms | 336 KB | Output is correct |
6 | Correct | 1 ms | 336 KB | Output is correct |
7 | Correct | 1 ms | 336 KB | Output is correct |
8 | Correct | 1 ms | 336 KB | Output is correct |
9 | Correct | 1 ms | 336 KB | Output is correct |
10 | Correct | 1 ms | 336 KB | Output is correct |
11 | Correct | 1 ms | 348 KB | Output is correct |
12 | Correct | 1 ms | 336 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 336 KB | Output is correct |
2 | Correct | 1 ms | 336 KB | Output is correct |
3 | Correct | 1 ms | 336 KB | Output is correct |
4 | Correct | 1 ms | 336 KB | Output is correct |
5 | Correct | 1 ms | 336 KB | Output is correct |
6 | Correct | 1 ms | 336 KB | Output is correct |
7 | Correct | 1 ms | 336 KB | Output is correct |
8 | Correct | 1 ms | 336 KB | Output is correct |
9 | Correct | 1 ms | 336 KB | Output is correct |
10 | Correct | 1 ms | 336 KB | Output is correct |
11 | Correct | 1 ms | 348 KB | Output is correct |
12 | Correct | 1 ms | 336 KB | Output is correct |
13 | Correct | 56 ms | 11360 KB | Output is correct |
14 | Correct | 51 ms | 11204 KB | Output is correct |
15 | Correct | 53 ms | 11356 KB | Output is correct |
16 | Correct | 54 ms | 11780 KB | Output is correct |
17 | Correct | 52 ms | 11372 KB | Output is correct |
18 | Correct | 53 ms | 11456 KB | Output is correct |
19 | Correct | 60 ms | 11200 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 336 KB | Output is correct |
2 | Correct | 1 ms | 336 KB | Output is correct |
3 | Correct | 57 ms | 11460 KB | Output is correct |
4 | Correct | 57 ms | 11820 KB | Output is correct |
5 | Correct | 362 ms | 41704 KB | Output is correct |
6 | Incorrect | 356 ms | 42212 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 336 KB | Output is correct |
2 | Correct | 1 ms | 336 KB | Output is correct |
3 | Correct | 1 ms | 336 KB | Output is correct |
4 | Correct | 1 ms | 336 KB | Output is correct |
5 | Correct | 1 ms | 336 KB | Output is correct |
6 | Correct | 1 ms | 336 KB | Output is correct |
7 | Correct | 1 ms | 336 KB | Output is correct |
8 | Correct | 1 ms | 336 KB | Output is correct |
9 | Correct | 1 ms | 336 KB | Output is correct |
10 | Correct | 1 ms | 336 KB | Output is correct |
11 | Correct | 1 ms | 348 KB | Output is correct |
12 | Correct | 1 ms | 336 KB | Output is correct |
13 | Correct | 56 ms | 11360 KB | Output is correct |
14 | Correct | 51 ms | 11204 KB | Output is correct |
15 | Correct | 53 ms | 11356 KB | Output is correct |
16 | Correct | 54 ms | 11780 KB | Output is correct |
17 | Correct | 52 ms | 11372 KB | Output is correct |
18 | Correct | 53 ms | 11456 KB | Output is correct |
19 | Correct | 60 ms | 11200 KB | Output is correct |
20 | Correct | 75 ms | 11980 KB | Output is correct |
21 | Correct | 49 ms | 11204 KB | Output is correct |
22 | Correct | 58 ms | 11956 KB | Output is correct |
23 | Correct | 59 ms | 11452 KB | Output is correct |
24 | Correct | 48 ms | 11460 KB | Output is correct |
25 | Correct | 57 ms | 11968 KB | Output is correct |
26 | Correct | 54 ms | 11700 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 336 KB | Output is correct |
2 | Correct | 1 ms | 336 KB | Output is correct |
3 | Correct | 1 ms | 336 KB | Output is correct |
4 | Correct | 1 ms | 336 KB | Output is correct |
5 | Correct | 1 ms | 336 KB | Output is correct |
6 | Correct | 1 ms | 336 KB | Output is correct |
7 | Correct | 1 ms | 336 KB | Output is correct |
8 | Correct | 1 ms | 336 KB | Output is correct |
9 | Correct | 1 ms | 336 KB | Output is correct |
10 | Correct | 1 ms | 336 KB | Output is correct |
11 | Correct | 1 ms | 348 KB | Output is correct |
12 | Correct | 1 ms | 336 KB | Output is correct |
13 | Correct | 56 ms | 11360 KB | Output is correct |
14 | Correct | 51 ms | 11204 KB | Output is correct |
15 | Correct | 53 ms | 11356 KB | Output is correct |
16 | Correct | 54 ms | 11780 KB | Output is correct |
17 | Correct | 52 ms | 11372 KB | Output is correct |
18 | Correct | 53 ms | 11456 KB | Output is correct |
19 | Correct | 60 ms | 11200 KB | Output is correct |
20 | Correct | 1 ms | 336 KB | Output is correct |
21 | Correct | 1 ms | 336 KB | Output is correct |
22 | Correct | 57 ms | 11460 KB | Output is correct |
23 | Correct | 57 ms | 11820 KB | Output is correct |
24 | Correct | 362 ms | 41704 KB | Output is correct |
25 | Incorrect | 356 ms | 42212 KB | Output isn't correct |
26 | Halted | 0 ms | 0 KB | - |