T了,发生了什么??

P2925 [USACO08DEC] Hay For Sale S

大佬,不加判断会超时的
by haoyuedangkong @ 2018-08-14 17:27:23


@[kkkac01](/space/show?uid=25183) 名字~~可能危险~~
by andyli @ 2018-08-14 17:39:25


我A了
by kkkac01 @ 2018-08-14 17:39:58


这题卡我常数
by kkkac01 @ 2018-08-14 17:40:08


把所有i++改成++i,再把max改成三目运算符。。。。。
by kkkac01 @ 2018-08-14 17:40:46


@[kkkac01](/space/show?uid=25183) 大佬您就非得起这种名字。。。
by ShineEternal @ 2018-08-14 18:00:41


@[kkkac01](/space/show?uid=25183) 名字……
by Altria_Pendragon_ @ 2018-08-14 18:02:08


``` #include<iostream> #include<cmath> #include<cstdio> using namespace std; int n,h,f[200001],w[200001]; int main() { cin>>h>>n; for(register int i=1;i<=n;i++) { scanf("%d",&w[i]); for(register int j=h;j>=w[i];j--) f[j]=(f[j]>f[j-w[i]]+w[i])?f[j]:(f[j-w[i]]+w[i]); } cout<<f[h]; return 0; } ``` 可以这样优化一下常数,实测能过
by Ophelia @ 2018-09-02 20:25:55


@[kkkac01](/space/show?uid=25183) 为什么改成三目就能过。。。。
by 十七 @ 2018-11-21 15:46:03


@[十七](/space/show?uid=85317) 三目比if快啊
by kkkac01 @ 2018-11-21 21:04:47


|