RE求助,悬关!

P1208 [USACO1.3] 混合牛奶 Mixing Milk

@[a1111_xh1215](/user/1007287) 数组开小了,这题n有2e6级别,5000是m的范围
by querycol @ 2023-12-23 16:23:13


@[querycol](/user/478039) 这边建议看看题目,输入 $m$ 行,开到 $m$ 没问题啊
by Ace_FutureDream @ 2023-12-23 16:24:47


@[querycol](/user/478039) 5000可以
by a1111_xh1215 @ 2023-12-23 16:25:14


```cpp #include<bits/stdc++.h> using namespace std; struct sss { int c; int b; }a[5010]; bool xiaomao(sss x,sss y) { return x.c<y.c; } int main() { int n,m; cin>>n>>m; for(int i=1;i<=m;i++) { cin>>a[i].c>>a[i].b; } sort(a+1,a+1+m,xiaomao); long long tnt=0,nn=0; for(int i=1;i<=m;i++) { if(a[i].b+nn<n) { tnt+=a[i].c*a[i].b; nn+=a[i].b; } else { tnt+=(n-nn)*a[i].c; break; } } cout<<tnt; return 0; } ```
by _txb_ @ 2023-12-23 16:28:02


@[a1111_xh1215](https://www.luogu.com.cn/user/1007287) [能AC](https://www.luogu.com.cn/record/140692898)
by _txb_ @ 2023-12-23 16:29:01


@[tanxubin](/user/869291) 谢,已关
by a1111_xh1215 @ 2023-12-23 16:40:16


为什么cmp函数里边是≤就不行,改成<就好了?
by wangdelta @ 2024-01-12 15:25:34


@[wangdelta](/user/516406) 小于等于? 请问刚好等于这么排
by LoTLaneyyat @ 2024-01-23 20:47:20


|