#include <bits/stdc++.h>
using namespace std;
#define ld long double
long double dis(ld a,ld b,ld c,ld x,ld y)
{
return (abs(a*x+b*y+c))/sqrt(a*a+b*b);
}
struct node
{
long long x,y,w;
}p[2009];
int n;
const ld pi=acos(-1);
ld rad(ld x)
{
return x*pi/180;
}
struct pos
{
bool is;
ld x;
long long w;
};
#define first x
#define second y
struct cmp
{
bool operator() (pos a,pos b)
{
if(a.is!=b.is)return a.is<b.is;
if(a.is==0)return a.x>b.x;
return a.x<b.x;
}
};
const ld E=1e-8;
long long f[2009];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin>>n;
for(int i=1;i<=n;i++)cin>>p[i].x>>p[i].y>>p[i].w;
long long kq=0;
for(ld j=-1000;j<=1000;j+=0.1)
{
vector<pos>t;
ld a=j;
for(int i=1;i<=n;i++)
{
if(p[i].y>=a*p[i].x)t.push_back({1,dis(a,-1,0,p[i].x,p[i].y),p[i].w});
else t.push_back({0,dis(a,-1,0,p[i].x,p[i].y),p[i].w});
}
sort(t.begin(),t.end(),cmp());
int cnt=0;
for(int i=1;i<=n;i++)f[i]=0;
cnt++;
f[cnt]=t[0].w;
for(int i=1;i<t.size();i++)
{
if(t[i].is==t[i-1].is&&abs(t[i].x-t[i-1].x)<E)f[cnt]+=t[i].w;
else
{
cnt++;
f[cnt]=t[i].w;
}
}
long long tam=0, pre = 0;
for(int i=1;i<=cnt;i++)
{
tam += f[i];
kq = max(kq, tam - pre);
pre = min(pre, tam);
}
kq=max(kq,tam);
// if(kq==21)
// {
// cout<<a<<'\n';
// for(int i=1;i<=cnt;i++)cout<<f[i]<<'\n';
// for(auto i:t)cout<<i.is<<' '<<i.x<<' '<<i.w<<endl;
// break;
// }
}
ld a,b,c;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
for(int i=1;i<=1000;i++)
{
int x=rng()%n+1;
int y=rng()%n+1;
while(x!=y)y=rng()%n+1;
vector<pos>t;
a=1.0*(p[y].second-p[x].second);
b=-1.0*(p[y].first-p[x].first);
c=-1.0*p[x].first*(p[y].second-p[x].second)+p[x].second*(p[y].first-p[x].first);
for(int i=1;i<=n;i++)
{
if(p[i].y>=a*p[i].x)t.push_back({1,dis(a,-1,0,p[i].x,p[i].y),p[i].w});
else t.push_back({0,dis(a,-1,0,p[i].x,p[i].y),p[i].w});
}
sort(t.begin(),t.end(),cmp());
int cnt=0;
for(int i=1;i<=n;i++)f[i]=0;
cnt++;
f[cnt]=t[0].w;
for(int i=1;i<t.size();i++)
{
if(t[i].is==t[i-1].is&&abs(t[i].x-t[i-1].x)<E)f[cnt]+=t[i].w;
else
{
cnt++;
f[cnt]=t[i].w;
}
}
long long tam=0, pre = 0;
for(int i=1;i<=cnt;i++)
{
tam += f[i];
kq = max(kq, tam - pre);
pre = min(pre, tam);
}
kq=max(kq,tam);
}
cout<<kq;
return 0;
}
Compilation message
bulldozer.cpp: In function 'int main()':
bulldozer.cpp:58:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<pos>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
58 | for(int i=1;i<t.size();i++)
| ~^~~~~~~~~
bulldozer.cpp:105:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<pos>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
105 | for(int i=1;i<t.size();i++)
| ~^~~~~~~~~
bulldozer.cpp:84:7: warning: variable 'b' set but not used [-Wunused-but-set-variable]
84 | ld a,b,c;
| ^
bulldozer.cpp:84:9: warning: variable 'c' set but not used [-Wunused-but-set-variable]
84 | ld a,b,c;
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
121 ms |
460 KB |
Output is correct |
2 |
Correct |
98 ms |
348 KB |
Output is correct |
3 |
Correct |
92 ms |
344 KB |
Output is correct |
4 |
Correct |
102 ms |
344 KB |
Output is correct |
5 |
Correct |
93 ms |
456 KB |
Output is correct |
6 |
Correct |
90 ms |
456 KB |
Output is correct |
7 |
Correct |
91 ms |
456 KB |
Output is correct |
8 |
Correct |
91 ms |
348 KB |
Output is correct |
9 |
Correct |
92 ms |
348 KB |
Output is correct |
10 |
Correct |
89 ms |
344 KB |
Output is correct |
11 |
Correct |
2 ms |
348 KB |
Output is correct |
12 |
Correct |
2 ms |
348 KB |
Output is correct |
13 |
Correct |
2 ms |
344 KB |
Output is correct |
14 |
Correct |
2 ms |
468 KB |
Output is correct |
15 |
Correct |
3 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
96 ms |
460 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
96 ms |
460 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
96 ms |
460 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
121 ms |
460 KB |
Output is correct |
2 |
Correct |
98 ms |
348 KB |
Output is correct |
3 |
Correct |
92 ms |
344 KB |
Output is correct |
4 |
Correct |
102 ms |
344 KB |
Output is correct |
5 |
Correct |
93 ms |
456 KB |
Output is correct |
6 |
Correct |
90 ms |
456 KB |
Output is correct |
7 |
Correct |
91 ms |
456 KB |
Output is correct |
8 |
Correct |
91 ms |
348 KB |
Output is correct |
9 |
Correct |
92 ms |
348 KB |
Output is correct |
10 |
Correct |
89 ms |
344 KB |
Output is correct |
11 |
Correct |
2 ms |
348 KB |
Output is correct |
12 |
Correct |
2 ms |
348 KB |
Output is correct |
13 |
Correct |
2 ms |
344 KB |
Output is correct |
14 |
Correct |
2 ms |
468 KB |
Output is correct |
15 |
Correct |
3 ms |
348 KB |
Output is correct |
16 |
Incorrect |
96 ms |
460 KB |
Output isn't correct |
17 |
Halted |
0 ms |
0 KB |
- |