# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
785891 |
2023-07-17T18:00:28 Z |
MISM06 |
LIS (INOI20_lis) |
C++17 |
|
2182 ms |
159920 KB |
//0 1 1 0 1
//0 1 0 0 1
//1 0 0 1 1
//0 1 1 0 1
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx2")
using namespace std;
#define F first
#define S second
#define pb push_back
#define sze size()
#define all(x) x.begin() , x.end()
#define wall__ cout << "--------------------------------------\n";
#define kids int mid = (tl + tr) >> 1, cl = v << 1, cr = v << 1 | 1
#define kid1 int mid = (tl + tr) >> 1, cl = v1 << 1, cr = v1 << 1 | 1
#define kid2 int mid = (tl + tr) >> 1, cl = v2 << 1, cr = v2 << 1 | 1
#define file_io freopen("input.cpp", "r", stdin); freopen("output.cpp", "w", stdout);
typedef long long ll;
typedef long double dl;
typedef pair < int , int > pii;
typedef pair < int , ll > pil;
typedef pair < ll , int > pli;
typedef pair < ll , ll > pll;
typedef pair < int , pii > piii;
typedef pair < ll, pll > plll;
const ll N = 1e6 + 5;
const ll mod = 1e9 + 7;
const ll inf = 2e16;
const ll INF = 1e9 + 10;
const ll lg = 32;
int n, a[N], p[N], ord[N], b[N], ans = 0;
set < int > s[N];
struct segtree1 {
pii seg[N << 2];
int la[N << 2];
void build (int v = 1, int tl = 1, int tr = n) {
la[v] = 0;
if (tl == tr) {
seg[v] = {p[tl], -tl};
return;
} kids;
build(cl, tl, mid);
build(cr, mid + 1, tr);
seg[v] = min(seg[cl], seg[cr]);
}
void shift (int v, int tl, int tr) {
seg[v].F += la[v];
if (tl != tr) {
la[v << 1] += la[v];
la[v << 1 | 1] += la[v];
}
la[v] = 0;
}
void upd (int val, int l, int r, int v = 1, int tl = 1 , int tr = n) {
shift(v, tl, tr);
if (l > r) return;
if (l == tl && r == tr) {
la[v] += val;
shift(v, tl, tr);
return;
} kids;
upd(val, l, min(r, mid), cl, tl, mid);
upd(val, max(l, mid + 1), r, cr, mid + 1, tr);
seg[v] = min(seg[cl], seg[cr]);
}
int ask () {
shift(1, 1, n);
return -seg[1].S;
}
} place;
void calc (int o, int h) {
ans = max(ans, h);
s[h].insert(o);
auto it = s[h].upper_bound(o);
while(it != s[h].end()) {
int oo = *it;
if (b[oo] <= b[o]) break;
s[h].erase(it);
calc(oo, h + 1);
it = s[h].upper_bound(o);
}
}
void solve () {
cin >> n;
for (int i = 1; i <= n; i++) cin >> p[i] >> a[i];
place.build();
for (int i = 1; i <= n; i++) {
int it = place.ask();
b[i] = a[it];
ord[it] = i;
place.upd(1, 1, it - 1);
place.upd(INF, it, it);
}
for (int i = 1; i <= n; i++) {
int o = ord[i];
int x = a[i];
int h = 0;
for (int j = 1; j < a[i]; j++) {
auto it = s[j].lower_bound(o);
if (it == s[j].begin() || s[j].sze == 0) continue;
--it;
int oo = *it;
if (b[oo] >= x) continue;
else h = j;
}
++h;
calc(o, h);
cout << ans << '\n';
}
}
int main() {
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int t = 1;
// cin >> t;
while (t--) {solve();}
return 0;
}
/*
*/
//shrek is love;
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
39 ms |
78540 KB |
Output is correct |
2 |
Correct |
38 ms |
78556 KB |
Output is correct |
3 |
Correct |
46 ms |
78776 KB |
Output is correct |
4 |
Correct |
43 ms |
78780 KB |
Output is correct |
5 |
Correct |
46 ms |
78704 KB |
Output is correct |
6 |
Correct |
45 ms |
78676 KB |
Output is correct |
7 |
Correct |
42 ms |
78704 KB |
Output is correct |
8 |
Correct |
43 ms |
78668 KB |
Output is correct |
9 |
Correct |
42 ms |
78732 KB |
Output is correct |
10 |
Correct |
43 ms |
78752 KB |
Output is correct |
11 |
Correct |
49 ms |
78668 KB |
Output is correct |
12 |
Correct |
44 ms |
78732 KB |
Output is correct |
13 |
Correct |
45 ms |
78668 KB |
Output is correct |
14 |
Correct |
46 ms |
78764 KB |
Output is correct |
15 |
Correct |
45 ms |
78732 KB |
Output is correct |
16 |
Correct |
50 ms |
78796 KB |
Output is correct |
17 |
Correct |
49 ms |
78716 KB |
Output is correct |
18 |
Correct |
44 ms |
78704 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
39 ms |
78540 KB |
Output is correct |
2 |
Correct |
38 ms |
78556 KB |
Output is correct |
3 |
Correct |
46 ms |
78776 KB |
Output is correct |
4 |
Correct |
43 ms |
78780 KB |
Output is correct |
5 |
Correct |
46 ms |
78704 KB |
Output is correct |
6 |
Correct |
45 ms |
78676 KB |
Output is correct |
7 |
Correct |
42 ms |
78704 KB |
Output is correct |
8 |
Correct |
43 ms |
78668 KB |
Output is correct |
9 |
Correct |
42 ms |
78732 KB |
Output is correct |
10 |
Correct |
43 ms |
78752 KB |
Output is correct |
11 |
Correct |
49 ms |
78668 KB |
Output is correct |
12 |
Correct |
44 ms |
78732 KB |
Output is correct |
13 |
Correct |
45 ms |
78668 KB |
Output is correct |
14 |
Correct |
46 ms |
78764 KB |
Output is correct |
15 |
Correct |
45 ms |
78732 KB |
Output is correct |
16 |
Correct |
50 ms |
78796 KB |
Output is correct |
17 |
Correct |
49 ms |
78716 KB |
Output is correct |
18 |
Correct |
44 ms |
78704 KB |
Output is correct |
19 |
Correct |
229 ms |
94044 KB |
Output is correct |
20 |
Correct |
221 ms |
94016 KB |
Output is correct |
21 |
Correct |
296 ms |
93224 KB |
Output is correct |
22 |
Correct |
360 ms |
93304 KB |
Output is correct |
23 |
Correct |
248 ms |
93944 KB |
Output is correct |
24 |
Correct |
265 ms |
93960 KB |
Output is correct |
25 |
Correct |
327 ms |
93960 KB |
Output is correct |
26 |
Correct |
266 ms |
93988 KB |
Output is correct |
27 |
Correct |
272 ms |
93980 KB |
Output is correct |
28 |
Correct |
257 ms |
94072 KB |
Output is correct |
29 |
Correct |
282 ms |
93992 KB |
Output is correct |
30 |
Correct |
251 ms |
93900 KB |
Output is correct |
31 |
Correct |
413 ms |
93924 KB |
Output is correct |
32 |
Correct |
357 ms |
94072 KB |
Output is correct |
33 |
Correct |
397 ms |
94084 KB |
Output is correct |
34 |
Correct |
371 ms |
93992 KB |
Output is correct |
35 |
Correct |
386 ms |
93960 KB |
Output is correct |
36 |
Correct |
379 ms |
93960 KB |
Output is correct |
37 |
Correct |
361 ms |
93976 KB |
Output is correct |
38 |
Correct |
351 ms |
94056 KB |
Output is correct |
39 |
Correct |
371 ms |
94004 KB |
Output is correct |
40 |
Correct |
388 ms |
94092 KB |
Output is correct |
41 |
Correct |
189 ms |
91096 KB |
Output is correct |
42 |
Correct |
61 ms |
80848 KB |
Output is correct |
43 |
Correct |
230 ms |
90252 KB |
Output is correct |
44 |
Correct |
196 ms |
86348 KB |
Output is correct |
45 |
Correct |
53 ms |
79884 KB |
Output is correct |
46 |
Correct |
45 ms |
78844 KB |
Output is correct |
47 |
Correct |
107 ms |
84472 KB |
Output is correct |
48 |
Correct |
92 ms |
82500 KB |
Output is correct |
49 |
Correct |
50 ms |
79460 KB |
Output is correct |
50 |
Correct |
41 ms |
78820 KB |
Output is correct |
51 |
Correct |
80 ms |
82120 KB |
Output is correct |
52 |
Correct |
173 ms |
88200 KB |
Output is correct |
53 |
Correct |
159 ms |
86928 KB |
Output is correct |
54 |
Correct |
135 ms |
85972 KB |
Output is correct |
55 |
Correct |
70 ms |
80356 KB |
Output is correct |
56 |
Correct |
147 ms |
84852 KB |
Output is correct |
57 |
Correct |
88 ms |
81316 KB |
Output is correct |
58 |
Correct |
76 ms |
80916 KB |
Output is correct |
59 |
Correct |
47 ms |
79172 KB |
Output is correct |
60 |
Correct |
209 ms |
87292 KB |
Output is correct |
61 |
Correct |
42 ms |
78692 KB |
Output is correct |
62 |
Correct |
115 ms |
82844 KB |
Output is correct |
63 |
Correct |
74 ms |
80844 KB |
Output is correct |
64 |
Correct |
158 ms |
85132 KB |
Output is correct |
65 |
Correct |
148 ms |
84528 KB |
Output is correct |
66 |
Correct |
65 ms |
80184 KB |
Output is correct |
67 |
Correct |
118 ms |
82976 KB |
Output is correct |
68 |
Correct |
90 ms |
81648 KB |
Output is correct |
69 |
Correct |
137 ms |
84472 KB |
Output is correct |
70 |
Correct |
57 ms |
79864 KB |
Output is correct |
71 |
Correct |
2099 ms |
159804 KB |
Output is correct |
72 |
Correct |
2049 ms |
159816 KB |
Output is correct |
73 |
Correct |
2115 ms |
159904 KB |
Output is correct |
74 |
Correct |
2080 ms |
159920 KB |
Output is correct |
75 |
Correct |
2068 ms |
159856 KB |
Output is correct |
76 |
Correct |
2182 ms |
159804 KB |
Output is correct |