QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#447955#8528. Chordsucup-team3215WA 0ms3712kbC++20786b2024-06-19 04:26:412024-06-19 04:26:42

Judging History

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

  • [2024-06-19 04:26:42]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3712kb
  • [2024-06-19 04:26:41]
  • 提交

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;
    if (~t) for (int k = 0; ~maxl[t][k]; ++k) maxl[i][j + k] = max(maxl[i][j + k], min(l[i], maxl[t][k]));
    else maxl[i][j] = l[i];
  }
  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: 3580kb

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: 3712kb

input:

1
1 2

output:

1

result:

ok 1 number(s): "1"

Test #3:

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

input:

2
1 3
2 4

output:

1

result:

ok 1 number(s): "1"

Test #4:

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

input:

2
1 4
2 3

output:

2

result:

ok 1 number(s): "2"

Test #5:

score: -100
Wrong Answer
time: 0ms
memory: 3712kb

input:

3
3 5
1 4
2 6

output:

1

result:

wrong answer 1st numbers differ - expected: '2', found: '1'