Codevs 1997 Guardians ' challenge

Source: Internet
Author: User

/*I'm sorry to say that. The beginning of the situation is right is the transfer of time out of the problem itself also thought of the array translation but did not write down and the positive solution to pass by .... And then for a good transfer wrote a 4-dimensional time is not too late to reduce the dimension of the calculation of the space on the hand ... *8 Double forget the gorgeous direct memory limit exceeded while compiling I was 0 minutes after the exam wrote wrote in the original state write the array of translation and then reduce the dimension of the data too water is a*/#include<iostream>#include<cstdio>#include<cstring>#defineMAXN 210#defineBase 200using namespacestd;intn,l,k,p[maxn],c[maxn],sum;Doublef[2][maxn*Ten][maxn],ans;intMain () {scanf ("%d%d%d", &n,&l,&k); sum+=K;  for(intI=1; i<=n;i++) scanf ("%d",&P[i]);  for(intI=1; i<=n;i++) {scanf ("%d",&C[i]); if(c[i]!=-1) sum+=C[i]; } f[0][k+Base][0]=1;  for(intI=1; i<=n;i++)      {           for(intj=sum+Base; j>=0; j--)           for(intk=n;k>=0; k--)          {            if(k>0&&j>=c[i]) f[i&1][j][k]+=f[(I-1) &1][j-c[i]][k-1]*(Double(P[i])/100.0);//won thef[i&1][j][k]+=f[(I-1) &1][j][k]* (Double( --p[i])/100.0);//Lose the          }         for(intj=sum+Base; j>=0; j--)           for(intk=n;k>=0; k--) f[(i-1) &1][j][k]=0; }     for(intI=Base; i<=sum+Base; i++)       for(intj=l;j<=n;j++) ans+=f[n&1][i][j]; printf ("%.6f\n", ans); return 0;}

Codevs 1997 Guardians ' challenge

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.