#include <bits/stdc++.h>
#define ar array
#define int long long
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int mod = 1e9 + 7;
const int LOG = 20;
const int maxn = 1e5 + 5;
vector<pll> qus;
int bin_search(ll p) {
int l=0, r=qus.size()-1, ans=-1;
while(l <= r) {
int mid = (l + r) / 2;
if(qus[mid].first <= p) ans = mid, l = mid + 1;
else r = mid - 1;
}
return ans;
}
signed main() {
ios_base::sync_with_stdio(false);
cout.tie(0); cin.tie(0);
int n, m, q; cin >> n >> m >> q;
ll day = 1;
vector<int> L(m), R(m);
for(int i=0; i<m; i++) cin >> L[i] >> R[i];
for(int i=0; i<q; i++) {
ll x; cin >> x;
qus.push_back({ x, i });
}
sort(qus.begin(), qus.end());
vector<ll> ans(q), last(n+1);
for(int i=0; i<m; i++) {
for(int j=L[i]; j<=R[i]; j++) {
if(last[j]) {
int p = bin_search(day - last[j] - 1);
if(p > -1) ans[p]++;
}
last[j] = day++;
}
}
for(int i=q-2; i>=0; i--) ans[i] += ans[i+1];
for(int i=0; i<q; i++) qus[i].first = ans[i];
sort(qus.begin(), qus.end(), [&](pll a, pll b) { return a.second < b.second; });
for(auto x : qus) cout << x.first << " ";
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
404 KB |
Output is correct |
11 |
Correct |
0 ms |
344 KB |
Output is correct |
12 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
404 KB |
Output is correct |
11 |
Correct |
0 ms |
344 KB |
Output is correct |
12 |
Correct |
0 ms |
344 KB |
Output is correct |
13 |
Correct |
69 ms |
6900 KB |
Output is correct |
14 |
Correct |
50 ms |
6840 KB |
Output is correct |
15 |
Correct |
80 ms |
7100 KB |
Output is correct |
16 |
Correct |
79 ms |
7100 KB |
Output is correct |
17 |
Correct |
52 ms |
6844 KB |
Output is correct |
18 |
Correct |
86 ms |
7096 KB |
Output is correct |
19 |
Correct |
80 ms |
7100 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
79 ms |
7092 KB |
Output is correct |
4 |
Execution timed out |
2098 ms |
8376 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
404 KB |
Output is correct |
11 |
Correct |
0 ms |
344 KB |
Output is correct |
12 |
Correct |
0 ms |
344 KB |
Output is correct |
13 |
Correct |
69 ms |
6900 KB |
Output is correct |
14 |
Correct |
50 ms |
6840 KB |
Output is correct |
15 |
Correct |
80 ms |
7100 KB |
Output is correct |
16 |
Correct |
79 ms |
7100 KB |
Output is correct |
17 |
Correct |
52 ms |
6844 KB |
Output is correct |
18 |
Correct |
86 ms |
7096 KB |
Output is correct |
19 |
Correct |
80 ms |
7100 KB |
Output is correct |
20 |
Execution timed out |
2005 ms |
9660 KB |
Time limit exceeded |
21 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
404 KB |
Output is correct |
11 |
Correct |
0 ms |
344 KB |
Output is correct |
12 |
Correct |
0 ms |
344 KB |
Output is correct |
13 |
Correct |
69 ms |
6900 KB |
Output is correct |
14 |
Correct |
50 ms |
6840 KB |
Output is correct |
15 |
Correct |
80 ms |
7100 KB |
Output is correct |
16 |
Correct |
79 ms |
7100 KB |
Output is correct |
17 |
Correct |
52 ms |
6844 KB |
Output is correct |
18 |
Correct |
86 ms |
7096 KB |
Output is correct |
19 |
Correct |
80 ms |
7100 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
79 ms |
7092 KB |
Output is correct |
23 |
Execution timed out |
2098 ms |
8376 KB |
Time limit exceeded |
24 |
Halted |
0 ms |
0 KB |
- |