Submission #878836

# Submission time Handle Problem Language Result Execution time Memory
878836 2023-11-25T10:09:55 Z christosalexand Fountain (eJOI20_fountain) C++14
0 / 100
234 ms 1304 KB
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n,q;
    cin>>n>>q;
    int d[n], c[n];
    for (int i = 0; i<n; i++)
    {
        cin>>d[i]>>c[i];
    }
    while (q--)
    {
        int start, litres;
        cin>>start>>litres;
        int current = d[start-1];
        litres-=c[start-1];
        if (litres<=0)
        {
            cout<<start<<endl;
            continue;
        }
        bool b = false;
        int l = start-1;
        int r = n;
        int mid = 0;
        int ans = start-1;
        while(l<r)
        {
            mid = (l+r)/2;
            if (d[mid]>current)
            {
                ans = mid;
                r = mid-1;
            }
            else
            {
                l = mid+1;
            }
        }
        litres-=c[mid];
        if (litres<=0)
        {
            cout<<mid<<endl;
            b = true;
        }
        
        if (!b)
        {
            cout<<0<<endl;
        }
    }

    return 0;
}

Compilation message

fountain.cpp: In function 'int main()':
fountain.cpp:29:13: warning: variable 'ans' set but not used [-Wunused-but-set-variable]
   29 |         int ans = start-1;
      |             ^~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 234 ms 1304 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -