Submission #498049

# Submission time Handle Problem Language Result Execution time Memory
498049 2021-12-24T10:09:19 Z Karabasan Fountain (eJOI20_fountain) C++17
0 / 100
1 ms 460 KB
#include <bits/stdc++.h>
#define ll long long
#define fast1 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define int long long
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("fma,sse,sse2,sse3,avx")
#pragma GCC optimize("unroll-loops")

int n,m,k,q;
int d[1005];
int c[1005];
void solve()
{
    cin>>n>>q;
    for(int i=1;i<=n;i++)
        cin>>d[i]>>c[i];
    while(q--)
    {
        int a,b;
        cin>>a>>b;
        for(int i=a;i<=n;i++)
        {
            b-=c[i];
            if(b<=0)
            {
                cout<<i<<endl;
                break;
            }
            int son=i;
            while(d[i+1]<d[son])
                i++;
        }
        if(b>0)
            cout<<0<<endl;
    }
}
signed main()
{
    fast1
    //freopen ("lca.gir","r",stdin);
    //freopen ("lca.cik","w",stdout);
    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 1 ms 236 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 460 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 1 ms 236 KB Output isn't correct
3 Halted 0 ms 0 KB -