友情提示

P1440 求m区间内的最小值

快读配合cout即可
by exit0 @ 2020-02-03 13:42:39


??? @[萌新南凉北暖](/user/189181)
by KALY @ 2020-02-03 13:48:19


我没用STL也加了快读裂开了
by KALY @ 2020-02-03 13:48:52


后来把cout换掉了才a了
by KALY @ 2020-02-03 13:49:11


@[KALY](/user/287811) 那可能是您的算法问题
by exit0 @ 2020-02-03 13:53:56


```cpp #include<iostream> #include<cstdio> #define r read() using namespace std; inline int read() { char c=getchar(); int x=0,fh=0; while(c<'0'||c>'9'){fh|=c=='-';c=getchar();} while(c>='0'&&c<='9'){x=(x<<1)+(x<<3)+(c^48);c=getchar();} return fh?-x:x; } class deq { private: int a[2000001]; int start,over; public: inline void pop_back(){over--;} inline void pop_front(){start++;} inline int front(){return a[start];} inline int back(){return a[over-1];} inline bool empty(){return start==over;} inline void push_back(int x){a[over++]=x;} inline void que(){start=0,over=1;} }q; int a[2000001]; int main() { int n=r,m=r; a[0]=99999999; cout<<0<<endl; for(int i=1;i<n;i++) { a[i]=r; while(!q.empty()&&a[q.back()]>a[i])q.pop_back(); q.push_back(i); while(!q.empty()&&q.back()-q.front()>=m)q.pop_front(); cout<<a[q.front()]<<endl; } return 0; } ```
by KALY @ 2020-02-03 14:04:04


@[萌新南凉北暖](/user/189181) 怎么优化带佬
by KALY @ 2020-02-03 14:04:46


ac的那份换掉了cout。
by KALY @ 2020-02-03 14:06:01


@[KALY](/user/287811) 好吧,咱们算法不一样。如果你用线段树的话是不用cout的
by exit0 @ 2020-02-03 16:45:45


ios::sync_with_stdio(false)试试?
by Demons @ 2020-02-13 13:18:20


| 下一页