记录编号 603206 评测结果 AAAAATTTTTTTTTTTTTTT
题目名称 3574.[USACO21Feb Platinum]No Time to Dry 最终得分 25
用户昵称 Gravatar陆晨洗 是否通过 未通过
代码语言 C++ 运行时间 30.148 s
提交时间 2025-07-09 21:13:37 内存使用 4.08 MiB
显示代码纯文本
#include<bits/stdc++.h>
using namespace std;
int n;
int c[200010]={0};
int d[200010]={0};int d1;

int main()
{
    freopen("dry.in","r",stdin);
    freopen("dry.out","w",stdout);
    int q,a,b,ans,i,j;
    cin>>n>>q;
    for(i=1;i<=n;i++)
    {
        cin>>c[i];
    }
    for(i=1;i<=q;i++)
    {
        cin>>a>>b;
        d1=0;ans=0;
        for(j=a;j<=b;j++)
        {
            while(d[d1]!=0&&d[d1]>c[j])
            {
                d1--;
            }
            if(d[d1]!=c[j])
            {
                d1++;ans++;
                d[d1]=c[j];
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}