답안 #498045

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
498045 2021-12-24T10:06:14 Z Karabasan Fountain (eJOI20_fountain) C++17
0 / 100
1 ms 460 KB
#include <bits/stdc++.h>
#define ll long long
#define fast1 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("fma,sse,sse2,sse3,avx")
#pragma GCC optimize("unroll-loops")

int n,m,k,q;
int d[1005];
int c[1005];
void solve()
{
    cin>>n>>q;
    for(int i=1;i<=n;i++)
        cin>>d[i]>>c[i];
    while(q--)
    {
        int a,b;
        cin>>a>>b;
        for(int i=a;i<=n;i++)
        {
            b-=c[i];
            if(b<=0)
            {
                cout<<i<<endl;
                break;
            }
            int son=i;
            while(d[i+1]<d[son])
                i++;
        }
        if(b>0)
            cout<<0<<endl;
    }
}
signed main()
{
    fast1
    //freopen ("lca.gir","r",stdin);
    //freopen ("lca.cik","w",stdout);
    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 332 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 460 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 332 KB Output isn't correct
3 Halted 0 ms 0 KB -