19 #define REP(i, n) for(int i=0;i<int(n);i++)
20 #define foreach(it, c) for(typeof((c).begin()) it = (c).begin();it!=(c).end();++it)
21 #define ALL(x) (x).begin(),(x).end()
22 #define SORT(x) sort(ALL(x))
24 #define VI vector<int>
25 #define VS vector<string>
28 #define VP vector<pair<int,int> >
29 template <typename T
> void enqueue(vector
< T
> &H
, T par
){
32 while(e
!= 1 && par
< H
[e
/2] ){
37 template <typename T
> void dequeue(vector
< T
> &H
){
38 if( H
.size() == 1 ) return;
47 if( d
+1 <= e
&& H
[d
] > H
[d
+1] ) d
++;
48 if( H
[d
] > H
[f
] ) break;
60 vector
<pair
<int,int > > H2
;
61 H1
.PB(10000000); // DUMMY
62 for(i
=1;i
<30001;i
++)enqueue(H1
,i
);
63 H2
.PB(make_pair(1000000, 1234114));
65 REP(i
, 30010) ultima
[i
] = -1000;
70 if( aux
- 600 < ultima
[c
] ){
82 enqueue(H2
, make_pair(ultima
[c
], c
));
84 if( aux
- 600 >= ultima
[c
] ){
93 enqueue(H2
, make_pair(aux
, r
));