度度熊与邪恶大魔王
来源:互联网 发布:赤瞳 喜欢 知乎 编辑:程序博客网 时间:2024/06/10 04:45
传送门
#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 3
- 度度熊与邪恶大魔王
- 度度熊与邪恶大魔王
- 度度熊与邪恶大魔王
- 度度熊与邪恶大魔王
- 度度熊与邪恶大魔王
- 度度熊与邪恶大魔王
- 度度熊与邪恶大魔王
- 度度熊与邪恶大魔王
- 度度熊与邪恶大魔王
- 度度熊与邪恶大魔王
- 1003 度度熊与邪恶大魔王
- 度度熊与邪恶大魔王(DP)
- Hdu6082 度度熊与邪恶大魔王
- 度度熊与邪恶大魔王---动规
- hdu 6082 度度熊与邪恶大魔王
- HDOJ 6082 度度熊与邪恶大魔王
- 度度熊与邪恶大魔王_DP
- hdu6082-度度熊与邪恶大魔王
- at 语法
- 舌尖上的AOP
- Building a Space Station 【poj-2031】【最小生成树】
- 617E
- /*Alert,prompt,confirm*/
- 度度熊与邪恶大魔王
- 【分析】Ceph文件系统修复机制cephfs-data-scan(2)
- 智能一代云平台(四十一):在docker中部署项目Dubbo上识别为私有地址问题
- ajax 执行成功前,提示正在处理请稍后
- 2017"百度之星"程序设计大赛
- MySQL实用工具,如何连接到MySQL,获得数据库中的信息
- ES6 语法---变量的赋值与解析
- 1.19.ARM汇编指令集7之存储器访问指令(LDR和STR)
- POJ 1509 Glass Beads(最小表示法、后缀自动机)