1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
| # include <algorithm> # include <iostream> # include <cstring> # include <cstdio> # include <cmath> # define R register # define LL long long
using namespace std;
int l,w,n,ans;
struct pp{int x,y;}a[5010];
inline void in(R int &a){ R char c = getchar();R int x=0,f=1; while(!isdigit(c)){if(c == '-') f=-1; c=getchar();} while(isdigit(c)) x = (x<<1)+(x<<3)+c-'0',c = getchar(); a = x*f; }
inline bool cmp(R pp a,R pp b){return a.x<b.x||(a.x == b.x&&a.y<b.y);} inline bool cmp2(R pp a,R pp b){return a.y<b.y;}
inline void maxx(R int &a,const int b){a>b? 0:a=b;} inline void minn(R int &a,const int b){a<b? 0:a=b;}
inline int yg(){ in(l),in(w);in(n); for(R int i=1; i<=n; ++i) in(a[i].x),in(a[i].y); a[++n] = (pp){l,w}; sort(a+1,a+n+1,cmp); for(R int i=1; i<=n; ++i) { R int up = w,down = 0; R int j; for(j=i+1; j<=n; ++j) { if(a[j].y<=down||a[j].y>=up||a[j].x == a[i].x) continue; if((l-a[i].x)*(up-down) <= ans) break; maxx(ans,(a[j].x-a[i].x)*(up-down)); if(a[j].y==a[i].y) break; if(a[j].y>a[i].y) minn(up,a[j].y); else maxx(down,a[j].y); } if(j>n) maxx(ans,(l-a[i].x)*(up-down)); }
for(R int i=n; i>=1; --i) { R int up = w,down = 0; R int j; for(j=i-1; j>=1; --j) { if(a[j].y<=down||a[j].y>=up||a[j].x == a[i].x) continue; if(a[i].x*(up-down) <= ans) break; maxx(ans,(a[i].x-a[j].x)*(up-down)); if(a[j].y==a[i].y) break; if(a[j].y>a[i].y) minn(up,a[j].y); else maxx(down,a[j].y); } if(j<1) maxx(ans,a[i].x*(up-down)); } sort(a+1,a+n+1,cmp2); for(R int i=1; i<=n; ++i) maxx(ans,l*(a[i].y-a[i-1].y)); printf("%d",ans); return 0; }
int youngsc = yg(); int main(){;}
|