Cod sursă (job #417810)

Utilizator avatar hendrix Groza Iulia Diana hendrix IP ascuns
Problemă Lalele (clasele 9-10) Compilator cpp | 0,75 kb
Rundă concurs_7_10 Status evaluat
Dată 10 ian. 2019 14:22:23 Scor 40
#include <bits/stdc++.h>

using namespace std;
ifstream fin("lalele.in");
ofstream fout("lalele.out");

int n, d, x, k, num, nr, dr;
priority_queue<int> Q;

int main()
{
    fin >> n;
    while(k!=n)
    {
        fin >> d >> x;
        if(x>0)
        {
            k+=d;
            for(int i=1; i<=d; i++)
            Q.push(x+i-1-k);
            num+=d;
        }
        else
        {
            for(int i=1; i<=d; i++)
            {
                k++;
                nr = num/2 + num%2;
                for(int j=1; j<=nr; j++)
                {
                    dr=Q.top();
                    Q.pop();
                }
            fout << dr+k << "\n";
            num-=nr;
            }
        }
    }
return 0;}