记录编号 604595 评测结果 AAAAAAAAAA
题目名称 3034.[USACO Feb18 Silver]Snow Boots 最终得分 100
用户昵称 Gravatar陆晨洗 是否通过 通过
代码语言 C++ 运行时间 0.036 s
提交时间 2025-08-10 17:05:54 内存使用 3.66 MiB
显示代码纯文本
#include<bits/stdc++.h>
using namespace std;
int a[510]={0};
int c[510]={0};
int d[510]={0};
bool e[510]={0};
int main()
{
    freopen("snowboots_silver_18feb.in","r",stdin);
    freopen("snowboots_silver_18feb.out","w",stdout);
    int n,b,ans,i,j,k;
    cin>>n>>b;
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    for(j=1;j<=b;j++)
    {
        cin>>c[j]>>d[j];
    }
    e[1]=true;
    for(i=1;i<=b;i++)
    {
        for(j=1;j<=n;j++)
        {
            if(e[j]==true&&a[j]<=c[i])
            {
                for(k=j;k<=min(n,j+d[i]);k++)
                {
                    if(a[k]<=c[i])
                    {
                        e[k]=true;
                    }
                }
            }
        }
        if(e[n]==true)
        {
            ans=i;
            break;
        }
    }
    cout<<ans-1;
    return 0;
}