Submission #1024556

# Submission time Handle Problem Language Result Execution time Memory
1024556 2024-07-16T07:35:29 Z vjudge1 Fountain (eJOI20_fountain) C++17
30 / 100
72 ms 2132 KB
#include <bits/stdc++.h>

using namespace std;

int vkupno[100005];
int n, q;

int binarno(int rezervoar, int voda) {
    int l=rezervoar-1, r=n+1;
    while (l+1<r) {
        int mid=(l+r)/2;
        if (vkupno[mid]-vkupno[rezervoar-1]>=voda) r=mid;
        else l=mid;
    }
    return r;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> q;
    int dijametar[n+1], kapacitet[n+1];
    for (int i=1;i<=n;i++)
        cin >> dijametar[i] >> kapacitet[i];
    vkupno[0]=0;
    for (int i=1;i<=n;i++)
        vkupno[i]=vkupno[i-1]+kapacitet[i];
    vkupno[n+1]=INT_MAX;
    while (q--) {
        int r, v;
        cin >> r >> v;
        int rez=binarno(r, v);
        if (rez==n+1) cout << 0 << '\n';
        else cout << rez << '\n';
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 46 ms 2132 KB Output is correct
2 Correct 72 ms 2084 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -