#include<stdio.h>#include<string.h>#include<math.h>#include<iostream>#include<algorithm>#include<map>#include<set>#include<bitset>#include<vector>using namespace std;typedef int lld;#define pb push_back#define mp make_pair#define X first#define Y second#define inf 0xfffffff#define MAXN 1100#define L(x) (x<<1)#define R(x) ((x<<1)|1)const double EPS = 1e-6;struct node{ int a,b,x,y; long long h;}p[1103];bool solve(int x,int y,int xx,int yy){if(x>y)swap(x,y);if(xx>yy)swap(xx,yy);if((xx>=x&&xx<=y)||(yy>=x&&yy<=y)||(xx<=x&&yy>=y))return true;return false;}int main(){ int n,m,c; while(scanf("%d%d%d",&n,&m,&c)!=EOF) { int i; for(i=0;i<c;i++) { scanf("%d%d%lld%d%d",&p[i].a,&p[i].b,&p[i].h,&p[i].x,&p[i].y); p[i].a=p[i].x+p[i].a-1; p[i].b=p[i].y+p[i].b-1; } long long ans; if(c) ans=p[0].h; else ans=0; for(i=0;i<c;i++) { long long ss=0; for(int j=0;j<i;j++) { bool f=false; f=solve(p[i].x,p[i].a,p[j].x,p[j].a); if(f) f=solve(p[i].y,p[i].b,p[j].y,p[j].b); if(f&&p[j].h>ss) ss=p[j].h; } p[i].h+=ss; if(p[i].h>ans) ans=p[i].h; } printf("%lldn",ans); }}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)