#include <iostream>
using namespace std;
int main()
{
int n, t;
cin >> n >> t;
int a[1000];
int max = 0;
int pos;
for (int i = 0; i < n; i ++)
{
cin >> a[i];
}
for (int j = 0; j < t; j ++)
{
for (int p = 0; p < n; p ++)
{
if (a[p] > max)
{
max = a[p];
pos = p;
}
}
for (int k = 0; k < n; k ++)
{
if (k == pos)
{
a[k] = 0;
}
else
{
a[k] += max / (n-1);
}
int f = max % (n-1);
{
if (pos <= f - 1)
{
for (int x = 0; x < f + 1; x ++)
{
if (x != pos)
{
a[x] += 1;
}
}
}
else
{
for (int y = 0; y < f; y ++)
{
a[y] += 1;
}
}
}
}
pos = pos + 1;
cout << pos << endl;
}
}
so basically first i grabed an array and i made the initial array and wrote a code to find the maximum and named the position and used the remainders to do it and repeated. but however the result is not correct and i dont know why im wrong. can someone help me?

