QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#835922#1359. Setting MapsIlvHJWA 0ms3624kbC++14934b2024-12-28 15:28:532024-12-28 15:29:02

Judging History

你现在查看的是最新测评结果

  • [2024-12-28 15:29:02]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3624kb
  • [2024-12-28 15:28:53]
  • 提交

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