Example #1
0
vector<Item> fixItems(vector<Item>& curItems, int curRoadId)
{
	vector<Item> goodItems;
	VD sps;
	int curTime = -1;

	for (int i = 0; i < (int)curItems.size(); i++)
	{
		if ( curItems[i].time == curTime )
		{
			sps.push_back(curItems[i].speed);
		}
		else
		{
			if ( !sps.empty() ) 
				goodItems.push_back(Item(curTime, MedianValue(sps)));
			sps.clear();
			sps.push_back(curItems[i].speed);
			curTime = curItems[i].time;
		}
	}

	if ( !sps.empty() ) 
		goodItems.push_back(Item(curTime, MedianValue(sps)));

	return goodItems;
}
Example #2
0
void init(VD & t, int & n, PDD * p, PDD & a, PDD & b) {
	t.clear();
	double tmp;
	for (int i = 0; i < n; ++i) {
		scanf("%lf", &tmp);
		t.PB(tmp);
	}
	std::sort(t.begin(), t.end());
	t.erase(std::unique(t.begin(), t.end()), t.end());
	n = t.size();
	for (int i = 0; i < n; ++i) {
		p[i] = at(a, b, t[i]);
	}
}