1193. Up the Stairs

来源:互联网 发布:国泰安经济金融数据库 编辑:程序博客网 时间:2024/06/05 13:21
#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;}

0 0
原创粉丝点击