codemA3倒水题( 二分)

来源:互联网 发布:领航时时彩软件 编辑:程序博客网 时间:2024/05/16 10:56


垃圾 一直错错错

。。。

无奈

点击打开链接

#include <iostream>#include<algorithm>#include<cstring>#include<cstdio>using namespace std;const int maxn=100000+5;long long t[maxn];long long c[maxn]; int T,C,n; int ff;bool ju(long long x){    double  cc=C;    for(int i=0;i<n;i++)    {        if((x<min((long long )T*10000,t[i]))||(x>max((long long)T*10000,t[i])))        {              return 0;        }           cc-=(double)(t[i]*c[i]-x*c[i])/(x-(long long)T*10000);        //cout<<cc<<endl;        if(cc<0)            return 0;    }    return 1;}int main(){    cin>>n;    cin>>T>>C;    long long  x,y;    long long mi,ma;    int flag=0;    for(int i=0;i<n;i++)    {        cin>>x>>y;        t[i]=x*10000;        c[i]=y;        if(i==0)        {            mi=x*10000;            ma=x*10000;        }        if(x>mi)            mi=x*10000;        if(x<ma)            ma=x*10000;    }    if(T*10000<mi)      mi=T*10000;    if(T*10000>ma)       ma=T*10000;    int ju2=0;        while(ma>mi+1)      {        int h=(ma+mi)/2;        cout<<ma<<" "<<mi<<" "<<" h="<<h<<endl;        if(ju(h))         {             mi=h;         }        else            ma=h;          ff=0;           // cout<<"ss"<<endl;     }      double ans=(double)mi/10000;      if(ju(mi))     {         cout<<"Possible"<<endl;         printf("%.4f\n",ans);     }      else         cout<<"Impossible"<<endl;    return 0;}

有个问题(二分好像不适合这个题目)

有时判断条件会出现错误,可能是我判断条件没有写好


1  .测试用例:

测试用例:100 3617 741251368 5709 2063 948 985 6875 8807 600 4039 531 2100 1431 4124 5320 8713 560 4781 1022 2097 7321 2824 4895 3485 4405 9508 3082 4681 5456 3146 1917 9243 4995 8627 5973 7266 3309 2286 7190 2379 7116 5461 7265 2767 1411 5452 5452 8646 8152 313 6748 7015 5922 2618 5173 2453 3418 3003 860 3095 8124 8526 6582 2912 2560 9996 140 3118 7560 8956 858 1313 7209 9032 5379 4003 2865 8265 1670 4717 7305 6098 7568 8068 3296 4937 5711 9899 2074 7657 7746 4090 9348 5333 4395 6040 9040 9886 8856 316 2943 7359 2352 3260 1073 8414 9851 7228 8563 8970 6034 1609 2095 2735 1251 136 7420 200 4263 1965 3532 9382 1849 392 6337 5763 6944 2748 1857 1943 3054 843 8750 1046 6031 8398 3137 424 4840 2491 9559 277 9725 4462 5553 131 8123 7036 9016 7338 5703 4540 4395 7762 8663 7787 4874 7716 8265 8230 3563 3600 3688 1666 7804 5881 3214 6811 6678 8395 4798 5699 8927 9756 8968 8036 8734 7464 688 2922 555 6779 2453 4226 5021 8746 7839 7122 7800 8900 8783 5178 9580 777 5834 6204 3268 9612 480 5668 7102 8670对应输出应该为:Impossible你的输出为:Possible 



测试用例:100 3029 79817160 3826 1017 3988 2494 3545 9203 3275 1401 3894 6518 4460 8146 3500 5666 4047 5344 4012 2252 4600 4040 3084 5484 4686 1471 4032 8012 4041 8873 3879 1272 3562 2114 4718 1156 4422 2581 3931 6585 3141 6493 4097 6834 4541 3095 3062 8038 3350 9696 4320 912 4294 5098 3386 93 3918 3902 4638 9416 4763 9150 4100 2233 4011 9330 4044 8576 3503 6453 3919 8599 3591 4616 4160 289 3781 638 3142 2502 3833 4970 4618 6775 3414 6164 3530 9343 3211 1325 3080 5545 4475 5799 3099 4444 4167 3872 4709 9746 4656 886 4229 5975 3066 6482 4168 9566 3401 944 3894 3807 4688 1836 3152 2336 4684 154 3223 7122 4386 3142 4037 4659 4766 6797 3390 3127 3816 4829 4771 3698 3148 7570 4508 7570 3811 2290 4724 7525 4155 1910 3983 1853 3930 4618 3366 802 3732 8572 4677 5308 3796 6943 4769 3360 4018 1775 3917 7114 4426 9361 4096 5024 4110 3190 3325 3688 3324 2435 3302 1418 3088 8898 4112 795 4715 3813 3421 993 3604 9521 4355 6804 3233 2621 4131 2909 4084 6652 4623 3705 4527 3539 3496 2000 4734 4027 4727 4913 4407 3255对应输出应该为:Possible 3062.0000你的输出为:Impossible 



2.测试用例:

测试用例:100 8513 63594473 7880 6121 6761 5720 7467 1779 7827 8016 6151 994 7986 7504 6399 4832 7535 1800 6655 7419 6985 5550 6356 908 8347 5414 6627 846 8054 884 7757 4054 8400 7726 6433 7449 8402 7739 8086 1819 7161 176 6722 287 8236 909 7028 7912 7617 5021 8139 9590 8377 2183 8406 8162 6705 574 6816 2047 6364 4712 6559 9354 6096 5333 8359 8588 7878 2384 6865 5179 6568 5925 7472 2944 7692 6938 7862 2247 6618 2539 8345 8883 6381 5040 7604 1376 7670 5110 7682 3424 7428 2229 6084 4964 7070 5933 6710 3338 8175 6664 7273 3581 8147 336 7982 8480 6532 3734 7033 1938 6582 5269 6580 53 6867 6924 8435 8627 8440 1205 7259 8209 6243 7533 6679 3701 7622 3078 6696 4488 7950 1909 7827 5035 7403 7299 7821 8576 6390 595 8070 3660 6372 4040 6919 8877 7522 1494 7612 9351 6208 2259 6568 8839 6648 3437 6748 9610 7621 2284 7354 8961 6102 8520 7553 9143 6875 3864 8425 3205 6367 4586 7221 3027 7284 6930 6962 2295 8183 2112 6654 3829 6477 8262 6424 515 6305 7912 7232 8215 6453 576 6784 743 8202 7525 7044 1268 6998 310对应输出应该为:Possible 8504.1451你的输出为:Impossible