Pentru această operație este nevoie să te autentifici.

Cod sursă (job #485828)

Utilizator avatar edyman Sandu Eduard edyman IP ascuns
Problemă Lalele (clasele 9-10) Compilator cpp | 0,54 kb
Rundă Arhiva de probleme Status evaluat
Dată 12 sept. 2019 22:00:43 Scor 100
#include <bits/stdc++.h>

using namespace std;
int x,d,a[5000100],n,k,r;
ifstream fin("lalele.in");
ofstream fout("lalele.out");
int main()
{
   fin>>n;
   while(fin>>d>>x)
   {
       if(x!=0)
       {
           r+=d;
           for(int i=1;i<=d;i++)
            a[++k]=x+i-1-r;
       }
       else
       {
           for(int i=1;i<=d;i++)
           {
               r++;
               nth_element(a+1,a+k/2+1,a+k+1);
               fout<<a[k/2+1]+r<<'\n';
               k/=2;
           }
       }
   }
   return 0;
}