Submission #863979

# Submission time Handle Problem Language Result Execution time Memory
863979 2023-10-21T15:34:17 Z FIFI_cpp Fountain (eJOI20_fountain) C++17
0 / 100
1500 ms 3352 KB
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <stdio.h>
#include <math.h>
#include <queue>
#include <stack>
#include <deque>
#include <fstream>
#include <iterator>
#include <set>
#include <map>
#include <iomanip>
#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
vector<pair<int, int>> reservoir;
int n,q;
int recur(int node,int quantity)
{
    bool found = false;
    if (quantity <= reservoir[node].second)
    {
        return node + 1;
    }
    int i = 0;
    for (i = node + 1;i < n;i++)
    {
        if (reservoir[i].first > reservoir[node].first)
        {
            found = true;
            break;
        }
    }
    if (!found)
        return 0;
    return recur(i,quantity - reservoir[i].second);
}

int main() {
    fast
    cin >> n >> q;
    for (int i = 0;i < n;i++)
    {
        int d,c;
        cin >> d >> c;
        reservoir.push_back({d,c});
    }
    for (int i = 0;i < q;i++)
    {
        int r,v;
        cin >> r >> v;
        cout << recur(r - 1,v) << endl;
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 452 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1578 ms 3352 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 452 KB Output isn't correct
2 Halted 0 ms 0 KB -