コード例 #1
0
ファイル: 372C.cpp プロジェクト: yancouto/maratona-sua-mae
inline void enqueue(ll x) {
	q.push(x);
	while(!dq.empty() && x < dq.back()) dq.pop_back();
	dq.push_back(x);
}
コード例 #2
0
ファイル: BrainMemory.cpp プロジェクト: GMIS/GMIS
//返回一段逻辑,表达为文字
bool  CBrainMemory::RetrieveLogic(int64 RoomID,deque<tstring>& LogicList,tstring* Text/*=NULL*/,bool IsShunt /* = false*/){
	int64 CurrentRoomValue,RoomType; 
    int64  CurrentID = RoomID;

	//首先得到意义空间的信息
	GetRoomInfo(RoomID,CurrentRoomValue,RoomType);

	if(RoomType ==  MEMORY_ACT){//递归终止
		assert(Text != NULL);
		return RetrieveAction(RoomID,CurrentRoomValue,*Text,IsShunt);
	}
 
	if(RoomType == MEMORY_INSTINCT){
		tstring s;
	    if(!RetrieveText(RoomID,s))return false;
		s = _T("Custom Command : ") + s;
        s+=_T(';');
		LogicList.push_back(s);
		return true;
	}

	if(RoomType != MEMORY_SERIES && 
		RoomType != MEMORY_SHUNT)return false;
  
    int64 LogicType = RoomType;

	deque<int64> MeaingList;
    while(1)
	{
		//向上漫游,找到父空间空间的ID和逻辑明文,得记忆的形ID
		CppSQLite3Query Result = LBrainQuery("*",CurrentRoomValue,LB_CHILD_ID,CurrentID);
		if(Result.eof())return false;
		CurrentID = Result.getInt64Field(0);  //fatherID
		if(CurrentID == ROOT_SPACE)break;
		CurrentRoomValue = Result.getInt64Field(1); //fatherValuse
        MeaingList.push_front(CurrentRoomValue);
	} 

    if(Text) *Text = Format1024(_T("use logic %d"),LogicList.size());

	tstring LogicText = Format1024(_T("Logic %d: "),LogicList.size());
	LogicList.push_back(LogicText);

	tstring& NestLogicText = LogicList.back();

    IsShunt = RoomType == MEMORY_SHUNT;
	deque<int64>::reverse_iterator It = MeaingList.rbegin();

	while (It != MeaingList.rend())
	{
		CurrentRoomValue = *It;
		LogicText= _T("");
		if (!RetrieveLogic(CurrentRoomValue,LogicList,&LogicText,IsShunt))return false;
	    LogicText +=_T(',');
		NestLogicText += LogicText;
		It++;	
	}
  
	*NestLogicText.rbegin() =_T(';');
     
	return true;
}
コード例 #3
0
ファイル: 5410738_WA.cpp プロジェクト: seaify/poj-codes
int main()
{
	//freopen("in.txt","r",stdin);
//	freopen("out1.txt","w+",stdout);
//	int T=0;
	while(EOF!=scanf("%d %d",&N,&F))
	{
		q.clear();
		sum[0]=0;opt=0;
		for(i=1;i<=N;++i)
		{
			scanf("%d",&a[i]);
			a[i]=a[i]*1000;
			if(a[i]>opt)
				opt=a[i];
			sum[i]=sum[i-1]+a[i];
		}
		if(F==N)
		{
			printf("%d\n",sum[N]/N);
			continue;
		}
		if(F==1) //////故N>=2
		{
			printf("%d\n",opt);
			continue;
		}
		cnt.x=0,cnt.y=0;
		q.push_front(cnt);
		opt=sum[F]/F;
		cnt.x=1,cnt.y=sum[1];
		q.push_front(cnt);
		if(sum[F+1]/(F+1)>opt)
			opt=sum[F+1]/(F+1);
	    if((sum[F+1]-sum[1])/F>opt)
			opt=(sum[F+1]-sum[1])/F; /////为判断出单调性,必须先压入2个点。。。
		for(i=F+2;i<=N;++i)
		{
		    cnt.x=i-F,cnt.y=sum[i-F];  ///可能压入的点
			while(test());
			q.push_front(cnt);
			cnt.x=i,cnt.y=sum[i];//寻找最优值。。。。
		    last=0;
			if(q.size()==1)
			{
				last=(cnt.y-q.back().y)/(cnt.x-q.back().x);
				continue;
			}
			t=q.back();    ////此时必存在2个元素
			q.pop_back();
			s=q.back();
			while((cnt.y-t.y)/(cnt.x-t.x)<(cnt.y-s.y)/(cnt.x-s.x))  ////保证至少2个元素...,last不断的扩大。。直到碰到一个比它小或等于的
			{
			   t=q.back();
			   q.pop_back();
			   if(q.empty())
				   break;
			   s=q.back();
			}
			q.push_back(t);
			last=(cnt.y-t.y)/(cnt.x-t.x);
			if(last>opt)
				opt=last;
		}
		printf("%d\n",opt);
	}
	return 0;
}
コード例 #4
0
ファイル: 328.cpp プロジェクト: roosephu/project-euler
void push(deque<pair<int, int>> &Q, pair<int, int> v) {
    while (!Q.empty() && Q.back() > v) {
        Q.pop_back();
    }
    Q.push_back(v);
}
コード例 #5
0
ファイル: gxl.cpp プロジェクト: jxxsoft/hypercube
bool GxlHandler::attribute(const wstring &name, const wstring &value)
{
	setAttribute(_elements.back(), name, trim(value));

	return true;
}