#include #include using namespace std ; #define mem(a,b) memset(a,b,sizeof(a)) const int maxn=100000+5; const int maxm=1000+5; long long a[maxn],b[maxn]; long long k[maxm],p[maxm]; long long cost[maxm][15]; long long max(long long a,long long b) { return a>b?a:b; } long long min(long long a,long long b) { return a>n>>m ) { long long max_def=0,max_att=0,max_hp=0; for(int i=0; i>a[i]>>b[i]; max_def=max(max_def,b[i]); max_hp=max(max_hp,a[i]); } for(int i=0; i>k[i]>>p[i]; max_att=max(max_att,p[i]); } if(max_def>=max_att) { cout<<"-1"<=j) { cost[j][i]=min(cost[j][i],k[ji]); } else { cost[j][i]=min(cost[j][i],cost[j-dam][i]+k[ji]); } } } } long long min_cost=0; for(int i=0;i