A,展开即可正常查看
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll,ll> pll; #define fi first #define se second #define pk push_back #define mk make_pair const ll N=2e5+10, inf=0x3f3f3f3f3f3f3f3f; ll n, a[N], pmi[N], smi[N], q, l, r; void work(){ scanf("%lld%lld",&n,&q); for(ll i=1;i<=n;i++){ scanf("%lld",&a[i]); } pmi[0]=n; for(ll i=1;i<=n;i++) pmi[i]=min(pmi[i-1],a[i]); smi[n+1]=n ; for(ll i=n;i>=1;i--) smi[i]=min(smi[i+1],a[i]); while(q--){ scanf("%lld%lld",&l,&r); printf("%lld\n",min(pmi[l-1],smi[r+1])); } return ; } int main() { // ll t; // for(cin>>t;t--;) work(); return 0; }
点个赞吧,谢谢对本题解的支持,进入博客即可查看系列