Finally, you can see me pull
t1, each rectangle has a length and width, may be omitted so that min {m long rectangular * min {}} maximum width
t1 called false greed, while $ a, b $ sort, each find $ a, b $ smaller deleted, then the sample can not be too large
In fact, a set of hand touch can not be over
3 1
6 5
1 10000
1 10000
According to my greedy deleted 110,000 (1 small), in fact, better delete 65
So very nervous, but also called false greedy, each time to find the smallest $ delta $,
Then a large sample and not too ...
A little collapse, and then casually played two basic greedy greedy policy of Mongolia is up
The sample is still not too big then,
Is this then want to go back is greedy,
Then threw
In fact, before t1 t2 with a like, versatile and greedy like that ah, he did not migrate over, deserved
How long to enumerate delete one cycle minimum, delete the remaining small width
Must ensure that such greed is right, this is the $ n ^ 2 $, then click on the optimization of $ n * log (n) $ a (Chairman tree optimization, binary optimization, optimization of the heap, various optimization can too)
Ha I do not know what I was thinking when exam
I'm so sucker ah
#include<bits/stdc++.h> using namespace std; #define ll long long #define A 111111 ll T,n,m; ll vis[A]; struct node{ ll a,b,id; node(){} node(const ll &x,const ll &y,const ll &z){a=x,b=y,id=z;} friend bool operator < (const node &x,const node &y){ return x.a<y.a; } }p1[A]; struct node2{ ll b; node2 () {} node2(const ll &y){b=y;} friend bool operator < (const node2 &x,const node2 &y){ return x.b>y.b; } }; priority_queue<node2>q; int main(){ // freopen("d2.in","r",stdin); // freopen("zj.out","w",stdout); scanf("%lld",&T); while(T--){ scanf("%lld%lld",&n,&m); while(q.size()) q.pop(); for(ll i=1;i<=n;i++){ ll x,y; scanf("%lld%lld",&x,&y); p1[i]=node(x,y,i); } sort(p1+1,p1+n+1); for(ll i=m+1;i<=n;i++) q.push(node2(p1[i].b)); ll maxx=0; for(ll i=m;i>=0;i--){ // printf("p1[i+1].a=%lld q.top()=%lld\n",p1[i+1].a,q.top().b); maxx=max(p1[i+1].a*q.top().b,maxx); q.push(node2(p1[i].b)); q.pop(); // IF (. P1 [I] .B <q.top () B) Continue; // must be deleted // the else q.pop (), q.push (node2 (P1 [I] .B)); } printf("%lld\n",maxx); } }