智力大冲浪

luogu loj

思路

按照扣钱从多到少的顺序,在规定时间从后往前排放活动,最终放不进去的就是不得不扣掉的

代码

#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int n;
struct fff{
	int t,w;
}a[10000];
int ans;
int tim[100000];
bool cmp(fff x,fff y){
	return x.w > y.w;
}
int main(){
	cin >> ans;
	cin >> n;
	for(int i = 1;i <= n; i++) cin >> a[i].t;
	for(int i = 1;i <= n; i++) cin >> a[i].w;
	sort(a+1,a+1+n,cmp);
	int tmp = 0;
	for(int i = 1;i <= n; i++){
		tmp = a[i].t;
		while(tim[tmp] && tmp >= 1) tmp--;
		tim[tmp]++;
		if(tmp <= 0) ans -= a[i].w;
	}
	cout << ans << endl;
	return 0;
}
posted @ 2020-01-13 15:37  CYC的幸福生活  阅读(67)  评论(0编辑  收藏  举报