比赛 |
ZLXSCDay1 |
评测结果 |
AWWWWWWWWA |
题目名称 |
刺杀特朗普 |
最终得分 |
20 |
用户昵称 |
铁策 |
运行时间 |
0.449 s |
代码语言 |
C++ |
内存使用 |
4.40 MiB |
提交时间 |
2016-03-18 19:17:06 |
显示代码纯文本
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#define INF 100000007
#define eps 1e-5
using namespace std;
struct point
{
long double time;
int delta;
point(long double t = 0, int d = 0):time(t), delta(d) {}
};
int dcmp(long double x, long double y)
{
if (fabs(x - y) <= eps)
return 0;
return (x < y ? 1 : -1);
}
bool operator <(point a, point b)
{
return (dcmp(a.time, b.time) == 1);
}
void get(int h, int s, long double &l, long double &r)
{
if (s < 0)
{
r = 1.0 * h / s - eps;
l = 0;
}
else
{
l = 1.0 * h / s + eps;
if (l < 0)
l = -2 * eps;
r = INF;
}
}
int n, cnt;
point thing[300010];
int main()
{
freopen("direction_of_reaction.in", "r", stdin);
freopen("direction_of_reaction.out", "w", stdout);
scanf("%d", &n);
for (int i = 0; i < n; i++)
{
int h1, s1, h2, s2, w, type;
scanf("%d%d%d%d%d%d", &h1, &s1, &h2, &s2, &w, &type);
long double l1, r1, l2, r2;
get(h1, s1, l1, r1);
get(h2, s2, l2, r2);
if (type)
{
long double l = min(l1, l2), r = max(r1, r2);
if (dcmp(l, r) >= 0)
{
thing[cnt++] = point(l, w);
thing[cnt++] = point(r, -w);
}
}
else
{
long double l = max(l1, l2), r = min(r1, r2);
if (dcmp(l, r) >= 0)
{
thing[cnt++] = point(l, w);
thing[cnt++] = point(r, -w);
}
}
}
sort(thing, thing + cnt);
int now = 0, ans = -INF;
double tem = 0;
for (int i = 0; i < cnt;)
{
if (!dcmp(thing[i].time, INF))
break;
int j = i + 1;
while (j < n && !dcmp(thing[j].time, thing[j - 1].time))
j++;
j--;
for (int k = i; k <= j; k++)
now += thing[k].delta;
if (now > ans)
{
ans = now;
tem = (double)thing[i].time;
}
i = j + 1;
}
if (ans <= 0)
printf("Stupid!\n");
else
printf("%.2f %d\n", tem - 273.15, ans);
return 0;
}