QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#447955 | #8528. Chords | ucup-team3215 | WA | 0ms | 3712kb | C++20 | 786b | 2024-06-19 04:26:41 | 2024-06-19 04:26:42 |
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[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'