Submission #463543

# Submission time Handle Problem Language Result Execution time Memory
463543 2021-08-11T09:59:39 Z Quentolosse Fountain (eJOI20_fountain) C++14
0 / 100
365 ms 1524 KB
//sous-tache 2
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int dichotomie (int litres, int max, int min, int reservoirDebut, vector<int>& reservoirs)
{
    if (max - 1 == min)
    {
        return max;
    }
    else if (reservoirs[(max + min) / 2] - reservoirs[reservoirDebut] > litres)
    {
        return dichotomie (litres, (max + min) / 2, min, reservoirDebut, reservoirs);
    }
    else
    {
        return dichotomie (litres, max, (max + min) / 2, reservoirDebut, reservoirs);
    }
}

int main ()
{
    int nbReservoirs, nbQuestions;
    pair<int,int> entree;
    vector<int> reservoirs;
    cin >> nbReservoirs >> nbQuestions;
    for (int i = 0; i < nbReservoirs; i++)
    {
        cin >> entree.first >> entree.second;
        reservoirs.push_back(entree.second);
    }
    for (int i = 1; i < nbReservoirs; i++)
    {
        reservoirs[i] += reservoirs[i-1];
    }
    for (int question = 0; question < nbQuestions; question++)
    {
        int resultat;
        cin >> entree.first >> entree.second;
        if (entree.second <= reservoirs [nbReservoirs - 1] - reservoirs[entree.first - 1])
        {
            resultat = dichotomie (entree.second, reservoirs.size() - 1, 0, entree.first - 2, reservoirs) + 1;
        }
        else
        {
            resultat = 0;
        }
        cout << resultat << endl;
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 365 ms 1524 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -