比赛 |
东方版NOIP模拟赛 |
评测结果 |
AAWAAAAAAA |
题目名称 |
Yukari |
最终得分 |
90 |
用户昵称 |
不错封ID几十块 |
运行时间 |
0.270 s |
代码语言 |
C++ |
内存使用 |
2.60 MiB |
提交时间 |
2015-10-28 21:59:15 |
显示代码纯文本
- #include<algorithm>
- #include<iostream>
- #include<cstdio>
- #include<cmath>
- #define maxn 300010
- #define inf 0x7fffffff
- using namespace std;
- struct td
- {
- int t;
- bool r;
- bool operator<(const td& a)const
- {
- return (t<a.t);
- }
- }mt[maxn];
- int n;
- int e;
- int xl,xr,yl,yr;
- int main()
- {
- freopen("camera.in","r",stdin);
- freopen("camera.out","w",stdout);
- int i;
- int tt;
- int mxt;
- int ans;
- int xopt,xedt;
- int yopt,yedt;
- int xi,yi,ui,vi;
- e=0;
- scanf("%d",&n);
- scanf("%d%d%d%d",&xl,&yl,&xr,&yr);
- for(i=1;i<=n;i++){
- scanf("%d%d%d%d",&xi,&yi,&ui,&vi);
- xopt=-1;
- xedt=-1;
- yopt=-1;
- yedt=-1;
- if(ui<0){
- if(xi>xr){
- xopt=((xr-xi)/ui)+((xr-xi)%ui!=0);
- xedt=((xl-xi)/ui);
- }
- else{
- if(xi>=xl){
- xopt=0;
- xedt=(xl-xi)/ui;
- }
- }
- }
- if(ui>0){
- if(xi<xl){
- xopt=((xl-xi)/ui)+((xl-xi)%ui!=0);
- xedt=((xr-xi)/ui);
- }
- else{
- if(xi<=xr){
- xopt=0;
- xedt=(xr-xi)/ui;
- }
- }
- }
- if(vi<0){
- if(yi>yr){
- yopt=((yr-yi)/vi)+((yr-yi)%vi!=0);
- yedt=((yl-yi)/vi);
- }
- else{
- if(yi>=yl){
- yopt=0;
- yedt=(yl-yi)/vi;
- }
- }
- }
- if(vi>0){
- if(yi<yl){
- yopt=((yl-yi)/vi)+((yl-yi)%vi!=0);
- yedt=((yr-yi)/vi);
- }
- else{
- if(yi<=yr){
- yopt=0;
- yedt=(yr-yi)/vi;
- }
- }
- }
- if(ui==0){
- if(xl<=xi && xi<=xr){
- xopt=0;
- xedt=inf;
- }
- }
- if(vi==0){
- if(yl<=yi && yi<=yr){
- yopt=0;
- yedt=inf;
- }
- }
- if(xopt!=-1 && yedt!=-1){
- tt=max(xopt,yopt);
- xi+=tt*ui;
- yi+=tt*vi;
- if(xl<=xi && xi<=xr && yl<=yi && yi<=yr){
- e++;
- mt[e].t=tt;
- mt[e].r=true;
- e++;
- mt[e].t=min(xedt,yedt);
- mt[e].r=false;
- }
- }
- }
- sort(&mt[1],&mt[e+1]);
- tt=0;
- mxt=-inf;
- for(i=1;i<=e;i++){
- tt+=(mt[i].r*2-1);
- if(tt>mxt){
- ans=mt[i].t;
- mxt=tt;
- }
- }
- printf("%d\n",ans);
- return 0;
- }