度度熊与邪恶大魔王

传送门

#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <algorithm>
using namespace std;

#define pi acos(-1)
#define endl '\n'
#define srand() srand(time(0));
#define me(x,y) memset(x,y,sizeof(x));
#define foreach(it,a) for(__typeof((a).begin()) it=(a).begin();it!=(a).end();it++)
#define close() ios::sync_with_stdio(0); cin.tie(0);
#define FOR(x,n,i) for(int i=x;i<=n;i++)
#define FOr(x,n,i) for(int i=x;i<n;i++)
#define W while
#define sgn(x) ((x) < 0 ? -1 : (x) > 0)
#define bug printf("***********\n");
typedef long long LL;
const int INF=0x3f3f3f3f;
const LL LINF=1e18+7;
const int dx[]= {-1,0,1,0,1,-1,-1,1};
const int dy[]= {0,1,0,-1,-1,1,-1,1};
const int maxn=2005;
const int maxx=1e5+100;
const double EPS=1e-7;
const int mod=998244353;
template<class T>inline T min(T a,T b,T c)
{
	return min(min(a,b),c);
}
template<class T>inline T max(T a,T b,T c)
{
	return max(max(a,b),c);
}
template<class T>inline T min(T a,T b,T c,T d)
{
	return min(min(a,b),min(c,d));
}
template<class T>inline T max(T a,T b,T c,T d)
{
	return max(max(a,b),max(c,d));
}
inline LL Scan()
{
	LL Res=0,ch,Flag=0;
	if((ch=getchar())=='-')Flag=1;
	else if(ch>='0' && ch<='9')Res=ch-'0';
	while((ch=getchar())>='0'&&ch<='9')Res=Res*10+ch-'0';
	return Flag ? -Res : Res;
}

LL dp[maxn][14];//dp[i][j]为花费 i为血 j为防 
LL a[maxx],b[maxx],k[maxn],p[maxn];

int main()
{
	//freopen( "in.txt" , "r" , stdin );
	int n,m;
	while(~scanf("%d%d",&n,&m))
	{
		for(int i=1;i<=n;i++)
		{
			a[i]=Scan();b[i]=Scan();
		}
		for(int i=1;i<=m;i++)
		{
			k[i]=Scan();p[i]=Scan();
		}
		for(int i=0;i<maxn;i++)
			for(int j=0;j<=10;j++)
				dp[i][j]=LINF;
		for(int i=0;i<=10;i++)//防御 
		{
			dp[0][i]=0;
			for(int j=1;j<=m;j++)
			{
				LL t=p[j]-i;//破防的伤害
				if(t<=0) continue;
				for(int p=t;p<=2003;p++)
				{
					dp[p][i]=min(dp[p-t][i]+k[j],dp[p][i]);
				}
			}
			for(int j=2002;j>=0;j--)//单调性 
			{
				dp[j][i]=min(dp[j][i],dp[j+1][i]);
			}
		}
		LL ans=0;
		for(int i=1;i<=n;i++)
			ans+=dp[a[i]][b[i]];
		if(ans>=LINF)
			puts("-1");
		else cout<<ans<<endl;
	}
}
		
				


  • 5
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值