比赛 东方版NOIP模拟赛 评测结果 AAAAAAAAAA
题目名称 Yukari 最终得分 100
用户昵称 Binary10 运行时间 0.333 s
代码语言 C++ 内存使用 1.84 MiB
提交时间 2015-10-28 21:08:19
显示代码纯文本
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<cmath>
#include<cctype>
#include<cstdio>
#include<string>
#include<vector>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
const int INF = 0x3f3f3f3f;
const int maxn = 1e5 + 10;
struct Event{
  int x;
  int type;
  bool operator < (const Event& rhs) const{
    return x < rhs.x || (x == rhs.x && type < rhs.type);
  }
}events[maxn*2];
int n, xl, yl, xr, yr;
int main()
{
  freopen("camera.in", "r", stdin);
  freopen("camera.out", "w", stdout);
  cin >> n >> xl >> yl >> xr >> yr;
  int x, y, u, v, e = 0;
  for(int i = 0; i < n; i++){
    scanf("%d%d%d%d", &x, &y, &u, &v);
    int L = 0, R = INF;
    if(u == 0){
      if(x < xl || x > xr) R = L - 1;
    }else if(u > 0) {
      L = max(L, (int)ceil((double)(xl - x) / u));
      R = min(R, (int)floor((double)(xr - x) / u));
    }else {
      L = max(L, (int)ceil((double)(xr - x) / u));
      R = min(R, (int)floor((double)(xl - x) / u));
    }
    if(v == 0){
      if(y < yl || y > yr) R = L - 1;
    }else if(v > 0) {
      L = max(L, (int)ceil((double)(yl - y) / v));
      R = min(R, (int)floor((double)(yr - y) / v));
    }else {
      L = max(L, (int)ceil((double)(yr - y) / v));
      R = min(R, (int)floor((double)(yl - y) / v));
    }
    if(L <= R){
      events[e++] = (Event){L, 0};
      events[e++] = (Event){R, 1};
    }
  }
  sort(events, events + e);
  int cnt = 0, ans = 0, t;
  for(int i = 0; i < e; i++){
    if(events[i].type == 0){
      ++cnt;
      if(cnt > ans){
        ans = cnt; t = events[i].x;
      }
    }
    else cnt--;
  }
  cout << t << endl;
  return 0;
}