이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
// author : aykhn
using namespace std;
typedef long long ll;
#define pb push_back
#define ins insert
#define mpr make_pair
#define all(v) v.begin(), v.end()
#define bpc __builtin_popcountll
#define pii pair<ll, ll>
#define pll pair<ll, ll>
#define fi first
#define se second
#define int ll
#define infll 0x3F3F3F3F3F3F3F3F
#define inf 0x3F3F3F3F
const int MXN = 2e5 + 5;
int n;
array<int, 2> p[MXN];
array<int, 3> q[MXN];
int res[MXN];
signed main()
{
ios_base::sync_with_stdio(0);
cin.tie(nullptr);
int Q;
cin >> n >> Q;
for (int i = 0; i < n; i++) cin >> p[i][0] >> p[i][1];
for (int i = 0; i < Q; i++) cin >> q[i][0] >> q[i][1], q[i][2] = i;
sort(p, p + n, [&](const array<int, 2> &a, const array<int, 2> &b)
{
return (a[0] == b[0] ? a[1] < b[1] : a[0] > b[0]);
});
sort(q, q + Q, [&](const array<int, 3> &a, const array<int, 3> &b)
{
return a[0] > b[0];
});
vector<int> s;
int j = 0;
for (int i = 0; i < Q; i++)
{
while (j < n && p[j][0] >= q[i][0])
{
auto it = upper_bound(all(s), p[j][1]);
if (it == s.end()) s.pb(p[j][1]);
else *it = p[j][1];
j++;
}
res[q[i][2]] = upper_bound(all(s), q[i][1]) - s.begin();
}
for (int i = 0; i < Q; i++) cout << res[i] << '\n';
}
# | 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... |