takapt0226's diary

競技プログラミングのことを書きます

POJ 3665 iCow

問題の解釈をがんばる

int main()
{
    int n, t;
    scanf("%d%d", &n, &t);
    if (n == 1)
    {
	while (t--)
	    puts("1");
	return 0;
    }

    pint song[2000];
    rep(i, n)
    {
	song[i].second = -(i + 1);
	scanf("%d", &song[i].first);
    }
    while (t--)
    {
	sort(song, song + n, greater<pint>());
	printf("%d\n", -song[0].second);

	int rate = song[0].first;
	song[0].first = 0;
	int a = rate / (n - 1);
	int upper = rate % (n - 1);
	if (-song[0].second <= upper)
	    ++upper;
	for (int i = 1; i < n; ++i)
	    song[i].first += a + (-song[i].second <= upper);
    }
}