记录编号 |
239093 |
评测结果 |
AWWWWWWWWA |
题目名称 |
[刺客信条III]刺杀特朗普 |
最终得分 |
20 |
用户昵称 |
铁策 |
是否通过 |
未通过 |
代码语言 |
C++ |
运行时间 |
0.432 s |
提交时间 |
2016-03-19 17:45:26 |
内存使用 |
4.89 MiB |
显示代码纯文本
#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;
}