Submission #576488

# Submission time Handle Problem Language Result Execution time Memory
576488 2022-06-13T06:38:47 Z ammar124 Fountain (eJOI20_fountain) C++14
30 / 100
1500 ms 2028 KB
#include <bits/stdc++.h>
#define endl '\n'
#define ll long long
using namespace std;
int const maxin = 1e5+6;
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int a,q;
    cin>>a>>q;
    pair<ll , ll> arr[a];
    for(int i=1;i<a+1;i++)
    {
        cin>>arr[i].first>>arr[i].second;
    }
    while(q--)
    {
        ll x,y;
        cin>>x>>y;
        ll last = arr[x].first;
        y-=arr[x].second;
        if(y <= 0)
            cout<<x<<endl;
        else
        {
            for(int i=x+1;i<a+1;i++)
            {
                if(arr[i].first > last)
                {
                    last = arr[i].first;
                    y-=arr[i].second;
                }
                if(y <= 0)
                {
                    cout<<i<<endl;
                    break;
                }
            }
            if(y > 0)
                cout<<0<<endl;
        }
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 268 KB Output is correct
4 Correct 2 ms 212 KB Output is correct
5 Correct 2 ms 340 KB Output is correct
6 Correct 2 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1585 ms 2028 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 268 KB Output is correct
4 Correct 2 ms 212 KB Output is correct
5 Correct 2 ms 340 KB Output is correct
6 Correct 2 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Execution timed out 1585 ms 2028 KB Time limit exceeded
9 Halted 0 ms 0 KB -