# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
463257 | Em1L | Fountain (eJOI20_fountain) | C++14 | 1574 ms | 2736 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n, q, x, y;
cin >> n >> q;
vector < pair <int, int> > v;
while (n--)
{
cin >> x >> y;
v.push_back(make_pair(x, y));
}
while (q--)
{
cin >> x >> y;
int prev = x - 1;
for (int i = x - 1; i < v.size(); i++)
{
if (y <= 0)
{
cout << i << '\n';
break;
}
if (prev == i or v[prev].first < v[i].first)
{
y -= v[i].second;
prev = i;
}
}
if (y > 0)
cout << '0' << '\n';
}
}
/*
6 5
n:
4 10
6 8
3 5
4 14
10 9
4 20
q:
1 25
6 30
5 8
3 13
2 8
*/
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |