# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
999583 |
2024-06-15T20:41:13 Z |
Nelt |
LIS (INOI20_lis) |
C++17 |
|
1442 ms |
135508 KB |
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
using namespace std;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll N = 1e6 + 5;
ll t[N];
set<pair<ll, ll>> v[N];
void upd(ll v)
{
for (; v < N; v |= (v + 1)) t[v]++;
}
ll sum(ll v)
{
ll ans = 0;
for (; v >= 0; v = (v & (v + 1)) - 1) ans += t[v];
return ans;
}
ll ans = 1;
void f(pair<ll, ll> x, ll lis)
{
ans = max(ans, lis);
while (!v[lis].empty() and v[lis].lower_bound(make_pair(x.first, -1)) != v[lis].end() and v[lis].lower_bound(make_pair(x.first, -1))->second > x.second)
f(*v[lis].lower_bound(make_pair(x.first, -1)), lis + 1), v[lis].erase(*v[lis].lower_bound(make_pair(x.first, -1)));
v[lis].insert(x);
}
void solve()
{
ll q;
cin >> q;
pair<ll, ll> qs[q];
for (ll i = 0; i < q; i++)
cin >> qs[i].first >> qs[i].second;
for (ll i = q - 1; i >= 0; i--)
{
ll l = 1, r = q;
while (l <= r)
{
ll mid = (l + r) >> 1;
if (mid - sum(mid) >= qs[i].first)
r = mid - 1;
else l = mid + 1;
}
qs[i].first = l;
upd(qs[i].first);
}
for (auto [p, x] : qs)
{
ll mx = 1;
for (ll i = x - 1; i >= 1; i--)
if (!v[i].empty() and v[i].begin()->first < p)
{
auto pos = *--v[i].lower_bound(make_pair(p, -1));
if (pos.second < x)
{
mx = i + 1;
break;
}
}
ans = max(ans, mx);
f(make_pair(p, x), mx);
cout << ans << endl;
}
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
ll t = 1;
// precomp();
// cin >> t;
for (ll cs = 1; cs <= t; cs++)
solve();
// cerr << "\nTime elapsed: " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms\n";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
51804 KB |
Output is correct |
2 |
Correct |
8 ms |
51804 KB |
Output is correct |
3 |
Correct |
10 ms |
52096 KB |
Output is correct |
4 |
Correct |
10 ms |
51960 KB |
Output is correct |
5 |
Correct |
21 ms |
52056 KB |
Output is correct |
6 |
Correct |
16 ms |
52060 KB |
Output is correct |
7 |
Correct |
14 ms |
52104 KB |
Output is correct |
8 |
Correct |
13 ms |
52060 KB |
Output is correct |
9 |
Correct |
11 ms |
52060 KB |
Output is correct |
10 |
Correct |
11 ms |
51856 KB |
Output is correct |
11 |
Correct |
11 ms |
52056 KB |
Output is correct |
12 |
Correct |
13 ms |
52060 KB |
Output is correct |
13 |
Correct |
14 ms |
52060 KB |
Output is correct |
14 |
Correct |
13 ms |
52060 KB |
Output is correct |
15 |
Correct |
14 ms |
52060 KB |
Output is correct |
16 |
Correct |
14 ms |
52056 KB |
Output is correct |
17 |
Correct |
13 ms |
52060 KB |
Output is correct |
18 |
Correct |
13 ms |
51960 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
51804 KB |
Output is correct |
2 |
Correct |
8 ms |
51804 KB |
Output is correct |
3 |
Correct |
10 ms |
52096 KB |
Output is correct |
4 |
Correct |
10 ms |
51960 KB |
Output is correct |
5 |
Correct |
21 ms |
52056 KB |
Output is correct |
6 |
Correct |
16 ms |
52060 KB |
Output is correct |
7 |
Correct |
14 ms |
52104 KB |
Output is correct |
8 |
Correct |
13 ms |
52060 KB |
Output is correct |
9 |
Correct |
11 ms |
52060 KB |
Output is correct |
10 |
Correct |
11 ms |
51856 KB |
Output is correct |
11 |
Correct |
11 ms |
52056 KB |
Output is correct |
12 |
Correct |
13 ms |
52060 KB |
Output is correct |
13 |
Correct |
14 ms |
52060 KB |
Output is correct |
14 |
Correct |
13 ms |
52060 KB |
Output is correct |
15 |
Correct |
14 ms |
52060 KB |
Output is correct |
16 |
Correct |
14 ms |
52056 KB |
Output is correct |
17 |
Correct |
13 ms |
52060 KB |
Output is correct |
18 |
Correct |
13 ms |
51960 KB |
Output is correct |
19 |
Correct |
112 ms |
65364 KB |
Output is correct |
20 |
Correct |
117 ms |
65620 KB |
Output is correct |
21 |
Correct |
288 ms |
65404 KB |
Output is correct |
22 |
Correct |
379 ms |
65620 KB |
Output is correct |
23 |
Correct |
185 ms |
65676 KB |
Output is correct |
24 |
Correct |
189 ms |
65616 KB |
Output is correct |
25 |
Correct |
201 ms |
65616 KB |
Output is correct |
26 |
Correct |
182 ms |
65620 KB |
Output is correct |
27 |
Correct |
210 ms |
65616 KB |
Output is correct |
28 |
Correct |
210 ms |
65620 KB |
Output is correct |
29 |
Correct |
183 ms |
65512 KB |
Output is correct |
30 |
Correct |
182 ms |
65524 KB |
Output is correct |
31 |
Correct |
212 ms |
65616 KB |
Output is correct |
32 |
Correct |
224 ms |
65540 KB |
Output is correct |
33 |
Correct |
218 ms |
65620 KB |
Output is correct |
34 |
Correct |
214 ms |
65620 KB |
Output is correct |
35 |
Correct |
219 ms |
65620 KB |
Output is correct |
36 |
Correct |
220 ms |
65532 KB |
Output is correct |
37 |
Correct |
216 ms |
65516 KB |
Output is correct |
38 |
Correct |
211 ms |
65620 KB |
Output is correct |
39 |
Correct |
220 ms |
65804 KB |
Output is correct |
40 |
Correct |
222 ms |
65868 KB |
Output is correct |
41 |
Correct |
87 ms |
62040 KB |
Output is correct |
42 |
Correct |
23 ms |
54108 KB |
Output is correct |
43 |
Correct |
217 ms |
61776 KB |
Output is correct |
44 |
Correct |
196 ms |
59732 KB |
Output is correct |
45 |
Correct |
20 ms |
53080 KB |
Output is correct |
46 |
Correct |
11 ms |
52060 KB |
Output is correct |
47 |
Correct |
62 ms |
55344 KB |
Output is correct |
48 |
Correct |
48 ms |
55632 KB |
Output is correct |
49 |
Correct |
17 ms |
52824 KB |
Output is correct |
50 |
Correct |
10 ms |
52060 KB |
Output is correct |
51 |
Correct |
42 ms |
55152 KB |
Output is correct |
52 |
Correct |
120 ms |
59940 KB |
Output is correct |
53 |
Correct |
102 ms |
59740 KB |
Output is correct |
54 |
Correct |
92 ms |
57180 KB |
Output is correct |
55 |
Correct |
27 ms |
53584 KB |
Output is correct |
56 |
Correct |
83 ms |
57684 KB |
Output is correct |
57 |
Correct |
38 ms |
54356 KB |
Output is correct |
58 |
Correct |
37 ms |
54096 KB |
Output is correct |
59 |
Correct |
15 ms |
52572 KB |
Output is correct |
60 |
Correct |
121 ms |
58896 KB |
Output is correct |
61 |
Correct |
10 ms |
52056 KB |
Output is correct |
62 |
Correct |
58 ms |
56060 KB |
Output is correct |
63 |
Correct |
39 ms |
54040 KB |
Output is correct |
64 |
Correct |
82 ms |
56140 KB |
Output is correct |
65 |
Correct |
74 ms |
57172 KB |
Output is correct |
66 |
Correct |
25 ms |
53340 KB |
Output is correct |
67 |
Correct |
59 ms |
56148 KB |
Output is correct |
68 |
Correct |
42 ms |
54708 KB |
Output is correct |
69 |
Correct |
69 ms |
55252 KB |
Output is correct |
70 |
Correct |
21 ms |
53084 KB |
Output is correct |
71 |
Correct |
1442 ms |
135372 KB |
Output is correct |
72 |
Correct |
1418 ms |
135396 KB |
Output is correct |
73 |
Correct |
1415 ms |
135472 KB |
Output is correct |
74 |
Correct |
1401 ms |
135508 KB |
Output is correct |
75 |
Correct |
1432 ms |
135396 KB |
Output is correct |
76 |
Correct |
1436 ms |
135508 KB |
Output is correct |