Submission #483929

# Submission time Handle Problem Language Result Execution time Memory
483929 2021-11-01T13:09:38 Z mdub Fountain (eJOI20_fountain) C++14
30 / 100
1500 ms 3320 KB
#include <iostream>
#include <vector>

using namespace std;

struct reservoir{
    int diameter = 0;
    int capacity = 0;
};
int main() {
    int numReservoirs, numQueries;
    cin >> numReservoirs >> numQueries;
    vector<reservoir> fountain(numReservoirs);
    for (int i = 0; i < numReservoirs; i++) {
        cin >> fountain[i].diameter >> fountain[i].capacity;
    }
    int iReservoir, numLiters, iLastReservoir;
    bool overflow = false;
    for (int i = 0; i < numQueries; i++) {
        overflow = false;
        cin >> iReservoir >> numLiters;
        iReservoir--;
        iLastReservoir = iReservoir;
        numLiters -= fountain[iReservoir].capacity;
        iReservoir++;
        if (numLiters <= 0) {
            iReservoir--;
        }
        while (numLiters > 0) {
            //cout << "iReservoir: " << iReservoir << " " << "numLiters: " << numLiters << " ";
            if (iReservoir == numReservoirs) {
                overflow = true;
                break;
            }
            else if (fountain[iReservoir].diameter > fountain[iLastReservoir].diameter) {
                //cout << fountain[iReservoir].diameter << "bigger than " << fountain[iLastReservoir].diameter << " ";
                numLiters -= fountain[iReservoir].capacity;
                if (numLiters <= 0) {
                    break;
                }
                iLastReservoir = iReservoir;
            }
            iReservoir++;
        }
        if (overflow) {
            cout << 0 << "\n";
        }
        else cout << ++iReservoir << "\n";
    }
}

# Verdict Execution time Memory Grader output
1 Correct 0 ms 292 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 2 ms 204 KB Output is correct
4 Correct 3 ms 204 KB Output is correct
5 Correct 5 ms 248 KB Output is correct
6 Correct 5 ms 332 KB Output is correct
7 Correct 4 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1590 ms 3320 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 292 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 2 ms 204 KB Output is correct
4 Correct 3 ms 204 KB Output is correct
5 Correct 5 ms 248 KB Output is correct
6 Correct 5 ms 332 KB Output is correct
7 Correct 4 ms 332 KB Output is correct
8 Execution timed out 1590 ms 3320 KB Time limit exceeded
9 Halted 0 ms 0 KB -