QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#447952 | #8528. Chords | ucup-team3215 | RE | 0ms | 3716kb | C++20 | 749b | 2024-06-19 04:23:56 | 2024-06-19 04:23:58 |
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;
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