第二和第四个点re

P1478 陶陶摘苹果(升级版)

wzm_ @ 2019-01-18 11:10:23

include<cstdio>

include<cstring>

include<algorithm>

include<cstring>

include<iostream>

include<cmath>

using namespace std; int cnt=0; struct point{ int x,y; point(int x=0,int y=0):x(x),y(y){} }; bool operator < (const point &e,const point &w){ if(e.y>w.y) return false; return true; } point g[10000000]; int main(){ int q,s; int b,i; scanf("%d %d",&q,&s); scanf("%d %d",&b,&i); int a=b+i; for(int r=0;r<q;r++){ scanf("%d %d",&g[r].x,&g[r].y); } sort(g,g+q); for(int p=0;p<q;p++){ if(a>=g[p].x) cnt++,s=s-g[p].y; if(s<0) { cnt--; break; } } printf("%d",cnt); }


by wzm_ @ 2019-01-18 11:19:52

_```cpp

include<cstdio>

include<cstring>

include<algorithm>

include<cstring>

include<iostream>

include<cmath>

using namespace std; int cnt=0; struct point{ int x,y; point(int x=0,int y=0):x(x),y(y){} }; bool operator < (const point &e,const point &w){ if(e.y>w.y) return false; return true; } point g[10000000]; int main(){ int q,s; int b,i; scanf("%d %d",&q,&s); scanf("%d %d",&b,&i); int a=b+i; for(int r=0;r<q;r++){ scanf("%d %d",&g[r].x,&g[r].y); } sort(g,g+q); for(int p=0;p<q;p++){ if(a>=g[p].x) cnt++,s=s-g[p].y; if(s<0) { cnt--; break; } } printf("%d",cnt); }


|