QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#447957 | #8528. Chords | ucup-team3215 | WA | 0ms | 3708kb | C++20 | 789b | 2024-06-19 04:28:21 | 2024-06-19 04:28:21 |
Judging History
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[r[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: 3664kb
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: 3540kb
input:
1 1 2
output:
1
result:
ok 1 number(s): "1"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3708kb
input:
2 1 3 2 4
output:
1
result:
ok 1 number(s): "1"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3652kb
input:
2 1 4 2 3
output:
2
result:
ok 1 number(s): "2"
Test #5:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
3 3 5 1 4 2 6
output:
2
result:
ok 1 number(s): "2"
Test #6:
score: 0
Accepted
time: 0ms
memory: 3664kb
input:
4 2 7 1 6 3 8 4 5
output:
2
result:
ok 1 number(s): "2"
Test #7:
score: 0
Accepted
time: 0ms
memory: 3664kb
input:
6 8 9 6 7 4 10 1 5 11 12 2 3
output:
5
result:
ok 1 number(s): "5"
Test #8:
score: 0
Accepted
time: 0ms
memory: 3632kb
input:
9 2 8 10 17 9 15 1 12 6 14 3 13 4 11 5 7 16 18
output:
4
result:
ok 1 number(s): "4"
Test #9:
score: -100
Wrong Answer
time: 0ms
memory: 3652kb
input:
13 8 16 2 13 14 23 10 11 7 17 6 24 12 18 9 20 4 15 19 21 3 26 1 25 5 22
output:
5
result:
wrong answer 1st numbers differ - expected: '6', found: '5'