Topic Link
meaning of the questions: given q times and ask x, Always ask will add a number to an array (array initially empty), you can each + x and -x operation, ask for any number of array your current array smallest integer not appear.
Ideas: Even E and F are made out actually stuck in this problem, I feel like thinking and observation skills can not. . . .
In fact, every time you can add unlimited X minus X should not think the result will only affect the modulus of x, find a space on the line.
#include<bits/stdc++.h>
using namespace std;
const int maxn=4e5+10;
int a[maxn];
int main()
{
int q,x,t,ans=0;
scanf("%d%d",&q,&x);
while(q--)
{
scanf("%d",&t);
a[t%x]++;
while(a[ans%x])
a[ans%x]--,ans++;
printf("%d\n",ans);
}
}