# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1272462 | wedonttalkanymore | Matryoshka (JOI16_matryoshka) | C++20 | 2093 ms | 7688 KiB |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define pii pair<ll, ll>
#define fi first
#define se second
const ll N = 2e5 + 5, inf = 1e18, mod = 1e9 + 7, block = 320, lim = 19;
int n;
pii a[N];
int q;
vector <pii> have;
bool cmp(pii x, pii y) {
if (x.fi == y.fi) return x.se > y.se;
return x.fi > y.fi;
}
void solve() {
sort(have.begin(), have.end(), cmp);
multiset <int> s;
for (int i = 0; i < have.size();) {
int l = i;
multiset <int> news;
while(l < have.size() && have[l].fi == have[i].fi) {
auto it = s.upper_bound(have[l].se);
if (it != s.end()) {
s.erase(it);
news.insert(have[l].se);
}
else news.insert(have[l].se);
l++;
}
for (auto x : news) s.insert(x);
i = l;
}
cout << s.size() << '\n';
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
if (fopen(".inp", "r")) {
freopen(".inp", "r", stdin);
freopen(".out", "w", stdout);
}
cin >> n >> q;
for (int i = 1; i <= n; i++) {
cin >> a[i].fi >> a[i].se;
}
// cin >> q;
for (int i = 1; i <= q; i++) {
int x, y;
cin >> x >> y;
have.clear();
for (int j = 1; j <= n; j++) {
if (a[j].fi >= x && a[j].se <= y) {
have.push_back({a[j].fi, a[j].se});
}
}
solve();
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | 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... |