제출 #731856

#제출 시각아이디문제언어결과실행 시간메모리
731856AtabayRajabliFountain (eJOI20_fountain)C++11
30 / 100
1566 ms3212 KiB
#include <bits/stdc++.h>
#define pb push_back
#define pii pair<int, int>
#define pll pair<ll, ll>
#define MAX 5e4 + 1
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 0x3F3F3F3F3F3F3F3FLL
#define OPT ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define sec second
#define fi first

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

int main()
{
    OPT

    int n, q;

    cin >> n >> q;
    vector<int> c(n+1), d(n+1);

    for(int i = 1; i<=n; i++)
    {
        cin >> d[i] >> c[i];
    }

    while(q--)
    {
        int r, v, ans = 0;

        cin >> r >> v;

        int temp = d[r];

        v-=c[r];
        ans = r;

        for(int i = r+1; i<=n; i++)
        {
            if(d[i] > temp && v>0)
            {
                temp = d[i];
                v -= c[i];
                ans = i;
            }
        }

        if(v>0)ans = 0;

        cerr << "ans : ";
        cout << ans << endl;
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...