搜索
您的当前位置:首页正文

1193. Up the Stairs

来源:好走旅游网
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
	int cases;
	cin >> cases;
	for(int count = 0; count < cases; count++) {
		int persons, floors, boxLeft;
		cin >> persons >> floors >> boxLeft;
		int time[persons];
		for(int i = 0; i < persons; i++) {
			int tmp1, tmp2;
			cin >> tmp1 >> tmp2;
			if(tmp2) {
				time[i] = 3 * floors - tmp1;
			}
			else {
				time[i] = floors + tmp1;
			}
		}
		sort(time, time+persons);
		int totalTimeLeft;
		if(boxLeft % persons) {
		    totalTimeLeft = boxLeft / persons * 2 * floors + time[boxLeft % persons - 1];
		}
		else {
			totalTimeLeft = (boxLeft / persons - 1) * 2 * floors + time[persons - 1];
		}
		cout << totalTimeLeft << endl;
	}
	return 0;
}

因篇幅问题不能全部显示,请点此查看更多更全内容

Top