Submission #484185

# Submission time Handle Problem Language Result Execution time Memory
484185 2021-11-02T10:27:11 Z mdub Fountain (eJOI20_fountain) C++14
30 / 100
1500 ms 3352 KB
#include <iostream>
#include <vector>

using namespace std;

struct reservoir{
    int diameter = 0;
    int capacity = 0;
};
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    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 1 ms 204 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 320 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 2 ms 332 KB Output is correct
6 Correct 2 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1592 ms 3352 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 320 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 2 ms 332 KB Output is correct
6 Correct 2 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Execution timed out 1592 ms 3352 KB Time limit exceeded
9 Halted 0 ms 0 KB -