| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 | 
|---|---|---|---|---|---|---|---|
| 783856 | AndrijaM | Fountain (eJOI20_fountain) | C++14 | 321 ms | 5376 KiB | 
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,q;
    cin>>n>>q;
    vector<pair<int,int>>v;
    int sum[n+1];
    sum[0]=0;
    for(int i=0;i<n;i++)
    {
        int x,y;
        cin>>x>>y;
        sum[i+1]=sum[i]+y;
        v.push_back({x,y});
    }
    while(q--)
    {
        int x,y;
        cin>>x>>y;
        if(n<=1005)
        {
            x--;
            int d=v[x].first;///x-1
            y-=v[x].second;
            if(y>0)
            x++;
            if(y>0)
            while(true)
            {
                if(x>=n)
                {
                    break;
                }
                if(d<v[x].first)
                {
                    y-=v[x].second;
                    d=v[x].first;
                }
                if(y<=0)break;
                x++;
            }
            x++;
            if(x>n)x=0;
            cout<<x<<endl;
        }
        else
        {
            int l=x;
            int r=n;
            while(l<r)
            {
                int mid=l+(r-l)/2;
                if(sum[mid]-sum[x-1]<y)
                {
                    l=mid+1;
                }
                if(sum[mid]-sum[x-1]>=y)
                {
                    r=mid;
                }
            }
            if(sum[n]-sum[x-1]<y)
            {
                l=0;
            }
            cout<<l<<endl;
        }
    }
    return 0;
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
