|  | 
|  | 
| back to board | hint Posted by Anton  12 Nov 2011 07:33Segment tree can help solve the problem. I've got AC 0.046s 512Kb.My steps:
 1. Read all input and build segment tree
 2. Get rmq(i, i + m - 1) for all needed i
Re: hint I cann't believe. It DON'T get TLE.
 for( long i = m-1; i < (long)arr.size(); ++i )
 cout << *max_element( arr.begin()+i+1-m, arr.begin()+i+1 ) << endl;
 
 =)
 
 
 
 | 
 | 
|