Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <algorithm>
- #define N 500005
- using namespace std;
- ifstream fin("piscina.in");
- ofstream fout("piscina.out");
- struct coord
- {
- int x,y;
- }a[N];
- int n,m,p;
- long long A;
- bool comp(coord A,coord B ){return A.y<B.y;}
- long long Solutie()
- {
- sort(a+1, a+p+1, comp);
- int pred;
- long long ar, armx;
- ar=armx=0;
- pred=1;
- for(int i=1;i<=p;i++)
- if(a[pred].x>a[i].x)
- {
- ar=a[pred].x;
- ar=1LL*ar*a[i].y;
- pred=i;
- armx=max(armx, ar);
- }
- return armx;
- }
- void F(int n1, int m1)
- {
- for(int i=1;i<=n;i++)
- if(a[i].x && a[i].y)
- {
- if(n1>0) a[i].x=n1-a[i].x;
- if(m1>0) a[i].y=m1-a[i].y;
- }
- }
- int main()
- {
- fin>>n>>m>>p;
- for(int i=1;i<=p;i++)fin>>a[i].x>>a[i].y;
- p++; a[p].x=n;a[p].y=0;
- p++; a[p].x=0; a[p].y=m;
- A=max(A, Solutie());
- F(n,0);
- A=max(A, Solutie());
- F(0, m);
- A=max(A, Solutie());
- F(n, 0);
- A=max(A, Solutie());
- fout<<A;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement