diff --git a/POJ/2823.cpp b/POJ/2823.cpp new file mode 100644 index 0000000..70788a3 --- /dev/null +++ b/POJ/2823.cpp @@ -0,0 +1,81 @@ +#include +#include +#include +#include +using namespace std; +#define MAXN 1000100 +int bus[MAXN]; + +int aval[MAXN]; +int apos[MAXN]; +int abegin,aend; + +int bval[MAXN]; +int bpos[MAXN]; +int bbegin,bend; + +int aans[MAXN]; +int bans[MAXN]; +int cnt; + +int main() +{ + int N,K; + scanf("%d %d",&N,&K); + abegin=0; + aend=0; + bbegin=0; + bend=0; + cnt=0; + /* + 8 3 + 1 3 -1 -3 5 3 6 7 + */ + for(int i=0;i=t) bend--; + bval[bend]=t; + bpos[bend++]=i; + } + aans[cnt]=aval[abegin]; + bans[cnt++]=bval[bbegin]; + for(int i=K;i=K) abegin++; + while(abegin=K) bbegin++; + while(bbegin=t) bend--; + bval[bend]=t; + bpos[bend++]=i; + + aans[cnt]=aval[abegin]; + bans[cnt++]=bval[bbegin]; + } + + for(int i=0;i