标签:nes rest red ems 数组 cst msu mem atom
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1797 Accepted Submission(s): 842
#include<cstdio> #include<cstring> #include<algorithm> using namespace std; const int N=250008; const int mod=1e9+7; int a[N],b[N],Max[N]; int main(){ int n; while(scanf("%d",&n)!=EOF){ for(int i=1;i<=n;++i) scanf("%d",&a[i]),a[i]-=i; for(int i=1;i<=n;++i) scanf("%d",&b[i]); Max[n]=a[n]; for(int i=n-1;i>=1;--i) Max[i]=max(Max[i+1],a[i]); sort(b+1,b+n+1); int ans1=Max[b[1]]-n-1,ans=Max[b[1]]; for(int i=2;i<=n;++i) ans=(ans+max(Max[b[i]],ans1))%mod; printf("%d\n",ans); } }
标签:nes rest red ems 数组 cst msu mem atom
原文地址:http://www.cnblogs.com/mfys/p/7273162.html