QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#94906 | #4368. Oil | nixnehc1 | WA | 2ms | 3592kb | C++14 | 1.6kb | 2023-04-08 09:08:44 | 2023-04-08 09:08:46 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N=2010;
int n,val[2*N],tot,ans;
struct Point
{
int x,y;
friend inline Point operator + (const Point &a,const Point &b) {return (Point){a.x+b.x,a.y+b.y};}
friend inline Point operator - (const Point &a,const Point &b) {return (Point){a.x-b.x,a.y-b.y};}
friend inline int operator * (const Point &a,const Point &b) {return a.x*b.y-a.y*b.x;}
friend inline bool operator == (const Point &a,const Point &b) {return (a.x==b.x)&(a.y==b.y);}
};
struct Line
{
Point a,b;
};
struct node
{
Point p;
int val;
}b[2*N];
Line a[N];
Point base;
int sign(Point x)
{
if(x.y>0 || (x.y==0 && x.x>0)) return 0;
return 1;
}
bool cmp(node a,node b)
{
if(sign(a.p)!=sign(b.p)) return sign(a.p)<sign(b.p);
return a.p*b.p>=0;
}
int work(Point x)
{
base=x;
tot=0;
int sum=0,res=0;
for(int i=1;i<=n;i++)
{
if(a[i].a==x || a[i].b==x) {sum+=a[i].b.x-a[i].a.x;continue;}
if(a[i].a.y<x.y) b[++tot]={a[i].a-base,(a[i].b.x-a[i].a.x)},b[++tot]={a[i].b-base,-(a[i].b.x-a[i].a.x)};
else b[++tot]={a[i].b-base,(a[i].b.x-a[i].a.x)},b[++tot]={a[i].a-base,-(a[i].b.x-a[i].a.x)};
}
sort(b+1,b+tot+1,cmp);
for(int i=1;i<=tot;i++) sum+=b[i].val,res=max(res,sum);
return res;
}
int main(void)
{
scanf("%d",&n);
for(int i=1,x0,x1,y;i<=n;i++)
{
scanf("%d%d%d",&x0,&x1,&y);
if(x0>x1) swap(x0,x1);
a[i]=(Line){(Point){x0,y},(Point){x1,y}};
}
for(int i=1;i<=n;i++) ans=max({ans,work(a[i].a),work(a[i].b)});
printf("%d\n",ans);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3592kb
input:
5 100 180 20 30 60 30 70 110 40 10 40 50 0 80 70
output:
200
result:
ok single line: '200'
Test #2:
score: 0
Accepted
time: 2ms
memory: 3532kb
input:
3 50 60 10 -42 -42 20 25 0 10
output:
25
result:
ok single line: '25'
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3496kb
input:
1 -100 180 20
output:
0
result:
wrong answer 1st lines differ - expected: '280', found: '0'