QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#835922 | #1359. Setting Maps | IlvHJ | WA | 0ms | 3624kb | C++14 | 934b | 2024-12-28 15:28:53 | 2024-12-28 15:29:02 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define IL inline
#define vec vector
#define eb emplace_back
#define emp emplace
IL void ckx(int &x, const int &y) { (x < y) && (x = y); }
IL void ckm(int &x, const int &y) { (x > y) && (x = y); }
const int maxN = 5e5 + 7;
int n;
struct seg {
int l, r;
} a[maxN];
priority_queue<int, vec<int>, greater<int>> A, B;
int main() {
cin.tie(nullptr) -> sync_with_stdio(false);
cin >> n;
for (int i = 1; i <= n; i++)
cin >> a[i].l >> a[i].r;
sort(a + 1, a + n + 1, [](const auto &A, const auto &B) {
return A.l < B.l;
});
int ans = 0;
for (int i = 1; i <= n; i++) {
if (!A.empty() && A.top() < a[i].l) {
ans++;
B.emp(a[i].r);
A.pop();
} else if (!B.empty() && B.top() < a[i].r) {
A.emp(B.top());
B.pop();
B.emp(a[i].r);
} else A.emp(a[i].r);
}
cout << ans << '\n';
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3624kb
input:
3 2 5 1 3 1 60 35 1 2 2 3
output:
0
result:
wrong answer Given vertex set from user output does not cover k vertices in some path