求hack
查看原帖
求hack
342868
qfpjm楼主2022/2/10 15:06

求一个较小的hack,WA#5

#include <bits/stdc++.h>

using namespace std;

struct node
{
	int s, d, idx;
}tt[1000005];

int n, t;

bool cmp(node x, node y)
{
	return x.s < y.s;
}

bool cmp2(node x, node y)
{
	return x.idx < y.idx;
}

int main()
{
	cin >> n >> t;
	for (int i = 1 ; i <= n ; i ++)
	{
		cin >> tt[i].s >> tt[i].d;
		tt[i].idx = i;
	}
	while (1)
	{
		sort (tt + 1, tt + 1 + n, cmp);
		for (int i = 1 ; i <= n ; i ++)
		{
			if (tt[i].s >= t)
			{
				cout << tt[i].idx;
				return 0;
			}
		}
		sort(tt + 1, tt + 1 + n, cmp2);
		for (int i = 1 ; i <= n ; i ++)
		{
			tt[i].s += tt[i].d;
		}
	}
}
2022/2/10 15:06
加载中...