求助!

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

```cpp #include<bits/stdc++.h> using namespace std; int a[10005],x,y,price=0,dj,maxm; int main(){ cin>>x>>y; for(int i=0;i<y;i++){ cin>>dj>>maxm; a[dj]=a[dj]+maxm; } for(int i=0;i<1000;i++){ if(x>a[i]){ x-=a[i]; price=price+a[i]*i; }else if(x>0){ price+=x*i; x=0; }else if(x=0){ break; } } cout<<price; return 0; } ```
by wsh88 @ 2023-06-02 20:03:16


请求关注
by wsh88 @ 2023-06-02 20:03:59


|