Submission #615547

# Submission time Handle Problem Language Result Execution time Memory
615547 2022-07-31T10:31:15 Z ArsBud Fountain (eJOI20_fountain) C++14
30 / 100
1500 ms 1556 KB
#include <iostream>

using namespace std;

int N, Q, k, y = 0, n, v, vid, r, g;
int m[200005], i[100005], t[100005];

void F(int x)
{
    if(i[y] < i[x])
    {
        m[y] = x;
        return;
    }
    if(m[y] > 0 || m[x] <= 0)
    {
        if(x == N)
        {
            m[y] = -1;
        }
        return;
    }
    F(m[x]);
}

void F1(int w)
{
    if(t[w] >= v)
    {
        v = 0;
        n = w;
        return;
    }
    if(v > t[w] && m[w] == -1)
    {
        n = -1;
        return;
    }
    v -= t[w];
    F1(m[w]);
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> N >> Q;
    r = (1 + N) / 2;
    for(int a = 1; a <= N; a++)
    {
        cin >> i[a] >> t[a];
    }
    m[N] = -1;
    for(int a = N; a >= 1; a--)
    {
        if(i[a] < i[a + 1])
        {
            m[a] = a + 1;
        }
        else
        {
            y = a;
            F(min(N, a + 2));
            if(m[a] == 0)
            {
                m[a] = N - 1;
            }
        }
    }
    for(int a = 0; a < Q; a++)
    {
        cin >> n >> v;
        n;
        F1(n);
        if(v < 0)
        {
            cout << 0 << '\n';
        }
        else
        {
            cout << max(n, 0) << '\n';
        }
    }
    return 0;
}

Compilation message

fountain.cpp: In function 'int main()':
fountain.cpp:73:9: warning: statement has no effect [-Wunused-value]
   73 |         n;
      |         ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 3 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1576 ms 1556 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 3 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Execution timed out 1576 ms 1556 KB Time limit exceeded
9 Halted 0 ms 0 KB -