记录编号 |
238919 |
评测结果 |
AAAAAAAAAA |
题目名称 |
[刺客信条III]刺杀特朗普 |
最终得分 |
100 |
用户昵称 |
Satoshi |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.955 s |
提交时间 |
2016-03-19 15:30:37 |
内存使用 |
18.72 MiB |
显示代码纯文本
#include <fstream>
#include <algorithm>
#include <map>
#include <iomanip>
#define N 100010
using namespace std;
typedef long double ld;
typedef long long ll;
ifstream in("direction_of_reaction.in");
ofstream out("direction_of_reaction.out");
int n,m=0;
int V[N]={0};
int ans=0;
ld INF=999999999;
ld eps=0.00000000001,data=273.15;
ld D[2*N],E[2*N];
bool l[N]={0};
ll d[N]={0},S[N]={0};
class segment
{
public:
int l,r;
int v;
void print()
{
out<<l<<' '<<r<<' '<<v<<endl;
}
}A[N];
class point
{
public:
ld l,r;
int v;
void make(ld a,ld b,int c)
{
l=a;
r=b;
v=c;
}
void print()
{
out<<l<<' '<<r<<' '<<v<<endl;
}
}B[2*N],C[N],G[N];
bool operator <(point a,point b)
{
if(a.l==b.l)return a.r<b.r;
return a.l<b.l;
}
map<ld,int > F;
void read()
{
int i,type;
ld H,S;
point P;
in>>n;
for(i=1;i<=n;i++)
{
in>>H>>S;
H=-H;S=-S;
if(S>0)B[i].make(0+eps,H/S-eps,0);
else B[i].make(H/S+eps,INF,0);
in>>H>>S;
H=-H;S=-S;
if(S>0)B[i+n].make(0+eps,H/S-eps,0);
else B[i+n].make(H/S+eps,INF,0);
in>>V[i];
in>>type;
if(B[i+n]<B[i])
{
P=B[i];
B[i]=B[i+n];
B[i+n]=P;
}
if(type==1)//并集
{
if(B[i].r>=B[i+n].l)
{
if(B[i].r>=B[i+n].r)//1 6 2 5=1 6
{
C[i]=B[i];
C[i].v=V[i];
}
else // 1 4 2 5=1 5
{
C[i].make(B[i].l,B[i+n].r,V[i]);
}
}
else // 1 1.9 5.1 7 取补集
{
C[i].make(B[i].r+eps,B[i+n].l-eps,-V[i]);
ans+=V[i];
}
}
else //交集
{
if(B[i].r<B[i].l)C[i].make(-1,-1,-1);//1 2 3 5交集为空
else //1 4 2 5 1 6 2 5= 2 4 2 5
{
C[i].make(B[i+n].l,min(B[i].r,B[i+n].r),V[i]);
}
}
}
//for(i=1;i<=n;i++)C[i].print();
for(i=1;i<=n;i++)if(C[i].l<0)C[i].l=0;
sort(C+1,C+n+1);
int tot=0;
for(i=1;i<=n;i++)if(C[i].l<=C[i].r)G[++tot]=C[i];//合法
//for(i=1;i<=tot;i++)G[i].print();
n=tot;
}
void lisanhua()
{
int i,o;
o=2*n+2;
for(i=1;i<=n;i++)D[i]=G[i].l;
for(i=1;i<=n;i++)D[i+n]=G[i].r;
D[2*n+1]=0;
D[2*n+2]=INF;
//排序去重离散化
sort(D+1,D+o+1);
for(i=1;i<o;i++)if(D[i]==D[i+1])D[i]=-1;
for(i=1;i<=o;i++)if(D[i]!=-1)E[++m]=D[i];
//out<<m<<endl;
for(i=1;i<=m;i++)F[E[i]]=i;
for(i=1;i<=n;i++)
{
A[i].l=F[G[i].l];
A[i].r=F[G[i].r];
A[i].v=G[i].v;
}
//for(i=1;i<=n;i++)A[i].print();
}
void add()
{
int i,name;
int flag;
ll best=-233333333;
for(i=1;i<=n;i++)
{
d[A[i].l]+=A[i].v;
d[A[i].r+1]-=A[i].v;
}
for(i=1;i<=m;i++)S[i]=S[i-1]+d[i];
S[0]=23333333;
for(i=m;i>=1;i--)
{
if(S[i]>=best)
{
best=S[i];
name=i;
}
}
//out<<name<<endl;
ans+=best;
if(ans<=0)out<<"Stupid!"<<endl;
else
{
out <<setprecision(2) <<std::fixed <<E[name-1]-data<<' ';
out<<ans<<endl;
}
}
void work()
{
lisanhua();
add();
}
int main()
{
read();
work();
return 0;
}