QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#447952#8528. Chordsucup-team3215RE 0ms3716kbC++20749b2024-06-19 04:23:562024-06-19 04:23:58

Judging History

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

  • [2024-06-19 04:23:58]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:3716kb
  • [2024-06-19 04:23:56]
  • 提交

answer

#include <algorithm>
#include <iostream>

using namespace std;

constexpr int N = 1e5;

int maxl[N][896], l[2 * N], r[N];

int main() {
  cin.tie(0)->sync_with_stdio(0);
  int n; cin >> n;
  for (int i = 0, a, b; i < n; ++i) cin >> a >> b, l[--b] = --a, r[i] = b;
  sort(r, r + n);
  maxl[0][0] = 2 * N;
  maxl[0][1] = l[r[0]];
  fill(maxl[0] + 2, maxl[1], -1);
  for (int i = 1; i < n; ++i) {
    copy(maxl[i - 1], maxl[i], maxl[i]);
    int j = 0; while (maxl[i - 1][j] > l[r[i]]) ++j;
    int t = lower_bound(r, r + n, l[r[i]]) - r - 1;
    for (int k = 0; ~maxl[t][k]; ++k) maxl[i][j + k] = max(maxl[i][j + k], min(l[i], maxl[t][k]));
  }
  int ans = 0;
  while (~maxl[n - 1][ans]) ++ans;
  cout << ans - 1 << '\n';
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3608kb

input:

5
1 2
4 10
7 9
3 5
6 8

output:

3

result:

ok 1 number(s): "3"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3716kb

input:

1
1 2

output:

1

result:

ok 1 number(s): "1"

Test #3:

score: -100
Runtime Error

input:

2
1 3
2 4

output:


result: