标签:set print parent 对象 step tor sts esc seq
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 0 Accepted Submission(s): 0
1 #include "cstdio" 2 #include "stdlib.h" 3 #include "iostream" 4 #include "algorithm" 5 #include "string" 6 #include "cstring" 7 #include "queue" 8 #include "cmath" 9 #include "vector" 10 #include "map" 11 #include "set" 12 #define db double 13 #define ll long long 14 #define inf 0x3f3f3f 15 using namespace std; 16 const int N=3e5+5; 17 const int mod=1e9+7; 18 #define rep(i,x,y) for(int i=x;i<=y;i++) 19 //char s[N],t[N]; 20 db pi=3.14; 21 //int s[N],w[N]; 22 int a[N],b[N]; 23 int pre[N]; 24 int main() 25 { 26 int n; 27 while(scanf("%d",&n)==1){ 28 for(int i=1;i<=n;i++){ 29 scanf("%d",a+i); 30 a[i]-=i; 31 } 32 memset(pre,0, sizeof(pre)); 33 for(int i=n;i>=1;i--) pre[i]=max(a[i],pre[i+1]); 34 for(int i=1;i<=n;i++) scanf("%d",&b[i]); 35 sort(b+1,b+n+1); 36 int ma=0; 37 ll ans=pre[b[1]]; 38 for(int i=2;i<=n;i++){ 39 ma=max(pre[b[1]]-n-1,pre[b[i]]); 40 ans=(ma+ans)%mod; 41 // printf("%d\n",ma); 42 } 43 printf("%lld\n",ans); 44 } 45 46 }
标签:set print parent 对象 step tor sts esc seq
原文地址:http://www.cnblogs.com/mj-liylho/p/7247765.html