样例过了,但全WA

P1230 智力大冲浪

@[xiezihan](/user/219814) 您能简单描述一下你解题的思路及思路的正确性吗?因为这是一个最优策略决定问题。
by metaphysis @ 2020-08-05 18:23:23


```cpp #include<bits/stdc++.h> using namespace std; inline void rd(int &s){ s=0;char c=getchar(); while(c<'0'||c>'9')c=getchar(); for(;c>='0'&&c<='9';c=getchar())s=(s<<1)+(s<<3)+(c^48); } bool s[505]; int n,ans; struct node{ int t,w; }a[505]; inline bool cmp(node x,node y){ return x.w>y.w; } int main (){ rd(ans);rd(n); for(int i=0;i<n;i++){ rd(a[i].t); } for(int i=0;i<n;i++){ rd(a[i].w); } sort(a,a+n,cmp); for(int i=0,j;i<n;i++){ for(j=a[i].t;s[j];j--); if(j==0)ans-=a[i].w; else s[j]=true; } cout<<ans; return 0; } ```
by _will_ @ 2022-01-19 20:50:27


|