UKE !?
  • 板块UVA1316 Supermarket
  • 楼主__why
  • 当前回复2
  • 已保存回复2
  • 发布时间2024/3/9 07:32
  • 上次更新2024/3/9 10:53:32
查看原帖
UKE !?
768270
__why楼主2024/3/9 07:32
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int maxn = 1e4+5;
int dp[maxn*maxn],n;
struct why{
	int d,p;
	friend bool operator < (why syl,why love){
		return syl.d<love.d;
	}
	void input(){
		cin>>p>>d;
	}
}a[maxn];
signed main(){
	while(cin>>n){
		memset(dp,0,sizeof(dp)); 
		for(int i = 1;i<=n;i++){
			a[i].input();
		}
		sort(a+1,a+n+1);
		int ans = 0;
		for(int i = 1;i<=n;i++){
			for(int j = a[i].d;j>0;j--){
				dp[j] = max(dp[j],dp[j-1]+a[i].p);
				ans = max(ans,dp[j]);
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}
2024/3/9 07:32
加载中...