#include<bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector,ofast")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
const ll MOD=1e9+7;
const ll MOD2=998244353;
const ll N=2e3+5;
const ld pi=acos(-1);
const ll INF=(1LL<<30);
const ld zero=1e-18;
#define SQ(i) ((i)*(i))
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define setp setprecision
#define lwb lower_bound
#define SZ(_a) (ll)_a.size()
ll n,x[N],y[N],c[N],pos[N],ans,ma[4*N],lma[4*N],rma[4*N],sum[4*N];
ll ymi=INF,yma=-INF;
vector<ll> lis;
vector<pair<ld,pll> > event;
void mod(ll nda,ll ndb){
ld cel=asin((y[nda]-y[ndb])/sqrt(SQ(y[nda]-y[ndb])+SQ(x[nda]-x[ndb])));
cel=(cel+pi/2>2*pi?cel+pi/2-2*pi:cel+pi/2);
//cout<<nda<<" "<<ndb<<" "<<cel/pi<<"\n";
event.pb(mp(cel,mp(nda,ndb)));
//cel=(cel+pi>2*pi?cel-pi:cel+pi);
//event.pb(mp(cel,mp(nda,ndb)));
}
void upd(ll id,ll l,ll r,ll to){
if(l==r-1){ma[id]=lma[id]=rma[id]=max(0LL,c[lis[l]]);sum[id]=c[lis[l]];return ;}
ll mid=(l+r)>>1;
if(to<mid)upd(id*2,l,mid,to);
else upd(id*2+1,mid,r,to);
sum[id]=sum[id*2]+sum[id*2+1];
lma[id]=max(lma[id*2],lma[id*2+1]+sum[id*2]);
rma[id]=max(rma[id*2]+sum[id*2+1],rma[id*2+1]);
ma[id]=max(max(ma[id*2],ma[id*2+1]),lma[id*2+1]+rma[id*2]);
}
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);
cin>>n;
REP(i,n){
cin>>x[i]>>y[i]>>c[i];
ymi=min(ymi,y[i]);
yma=max(yma,y[i]);
lis.pb(i);
}
sort(lis.begin(),lis.end(),[](ll A,ll B){
if(x[A]!=x[B])return (x[A]<x[B]);
return (y[A]>y[B]);
});
REP(i,n)pos[lis[i]]=i;
REP(i,n)upd(1,0,n,i);
ans=ma[1];
//if(ymi==yma){cout<<ans<<"\n";return 0;}
REP(i,n){
for(int j=i+1;j<n;j++){
mod(lis[i],lis[j]);
}
}
sort(event.begin(),event.end());
//for(auto i:event)cout<<i.Y.X<<" "<<i.Y.Y<<"\n";
REP(i,SZ(event)){
if(i&&abs(event[i].X-event[i-1].X)>zero)ans=max(ans,ma[1]);
ll nx=event[i].Y.X,ny=event[i].Y.Y;
swap(lis[pos[nx]],lis[pos[ny]]);
upd(1,0,n,pos[nx]);
upd(1,0,n,pos[ny]);
swap(pos[nx],pos[ny]);
}
cout<<ans<<"\n";
return 0;
}
Compilation message
bulldozer.cpp:2:61: warning: bad option '-fofast' to pragma 'optimize' [-Wpragmas]
2 | #pragma GCC optimize("unroll-loops,no-stack-protector,ofast")
| ^
bulldozer.cpp:29:23: warning: bad option '-fofast' to attribute 'optimize' [-Wattributes]
29 | void mod(ll nda,ll ndb){
| ^
bulldozer.cpp:38:31: warning: bad option '-fofast' to attribute 'optimize' [-Wattributes]
38 | void upd(ll id,ll l,ll r,ll to){
| ^
bulldozer.cpp:49:10: warning: bad option '-fofast' to attribute 'optimize' [-Wattributes]
49 | int main(){
| ^
bulldozer.cpp: In function 'int main()':
bulldozer.cpp:58:41: warning: bad option '-fofast' to attribute 'optimize' [-Wattributes]
58 | sort(lis.begin(),lis.end(),[](ll A,ll B){
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
748 KB |
Output is correct |
2 |
Correct |
2 ms |
748 KB |
Output is correct |
3 |
Correct |
2 ms |
748 KB |
Output is correct |
4 |
Correct |
2 ms |
748 KB |
Output is correct |
5 |
Correct |
2 ms |
748 KB |
Output is correct |
6 |
Correct |
3 ms |
748 KB |
Output is correct |
7 |
Correct |
2 ms |
748 KB |
Output is correct |
8 |
Correct |
2 ms |
748 KB |
Output is correct |
9 |
Correct |
2 ms |
748 KB |
Output is correct |
10 |
Correct |
2 ms |
748 KB |
Output is correct |
11 |
Correct |
0 ms |
364 KB |
Output is correct |
12 |
Correct |
0 ms |
364 KB |
Output is correct |
13 |
Correct |
0 ms |
364 KB |
Output is correct |
14 |
Correct |
1 ms |
364 KB |
Output is correct |
15 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
748 KB |
Output is correct |
2 |
Correct |
3 ms |
748 KB |
Output is correct |
3 |
Correct |
3 ms |
748 KB |
Output is correct |
4 |
Correct |
3 ms |
748 KB |
Output is correct |
5 |
Correct |
2 ms |
748 KB |
Output is correct |
6 |
Correct |
3 ms |
748 KB |
Output is correct |
7 |
Correct |
3 ms |
748 KB |
Output is correct |
8 |
Correct |
4 ms |
748 KB |
Output is correct |
9 |
Correct |
3 ms |
748 KB |
Output is correct |
10 |
Correct |
3 ms |
876 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
0 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
384 KB |
Output is correct |
14 |
Correct |
1 ms |
364 KB |
Output is correct |
15 |
Correct |
1 ms |
364 KB |
Output is correct |
16 |
Correct |
1 ms |
364 KB |
Output is correct |
17 |
Correct |
0 ms |
364 KB |
Output is correct |
18 |
Correct |
1 ms |
384 KB |
Output is correct |
19 |
Correct |
1 ms |
364 KB |
Output is correct |
20 |
Correct |
1 ms |
364 KB |
Output is correct |
21 |
Correct |
2 ms |
748 KB |
Output is correct |
22 |
Correct |
2 ms |
748 KB |
Output is correct |
23 |
Correct |
2 ms |
748 KB |
Output is correct |
24 |
Correct |
2 ms |
748 KB |
Output is correct |
25 |
Correct |
2 ms |
748 KB |
Output is correct |
26 |
Correct |
2 ms |
748 KB |
Output is correct |
27 |
Correct |
2 ms |
748 KB |
Output is correct |
28 |
Correct |
3 ms |
748 KB |
Output is correct |
29 |
Correct |
2 ms |
748 KB |
Output is correct |
30 |
Correct |
2 ms |
748 KB |
Output is correct |
31 |
Correct |
3 ms |
748 KB |
Output is correct |
32 |
Correct |
2 ms |
748 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
748 KB |
Output is correct |
2 |
Correct |
3 ms |
748 KB |
Output is correct |
3 |
Correct |
3 ms |
748 KB |
Output is correct |
4 |
Correct |
3 ms |
748 KB |
Output is correct |
5 |
Correct |
2 ms |
748 KB |
Output is correct |
6 |
Correct |
3 ms |
748 KB |
Output is correct |
7 |
Correct |
3 ms |
748 KB |
Output is correct |
8 |
Correct |
4 ms |
748 KB |
Output is correct |
9 |
Correct |
3 ms |
748 KB |
Output is correct |
10 |
Correct |
3 ms |
876 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
0 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
384 KB |
Output is correct |
14 |
Correct |
1 ms |
364 KB |
Output is correct |
15 |
Correct |
1 ms |
364 KB |
Output is correct |
16 |
Correct |
1 ms |
364 KB |
Output is correct |
17 |
Correct |
0 ms |
364 KB |
Output is correct |
18 |
Correct |
1 ms |
384 KB |
Output is correct |
19 |
Correct |
1 ms |
364 KB |
Output is correct |
20 |
Correct |
1 ms |
364 KB |
Output is correct |
21 |
Correct |
2 ms |
748 KB |
Output is correct |
22 |
Correct |
2 ms |
748 KB |
Output is correct |
23 |
Correct |
2 ms |
748 KB |
Output is correct |
24 |
Correct |
2 ms |
748 KB |
Output is correct |
25 |
Correct |
2 ms |
748 KB |
Output is correct |
26 |
Correct |
2 ms |
748 KB |
Output is correct |
27 |
Correct |
2 ms |
748 KB |
Output is correct |
28 |
Correct |
3 ms |
748 KB |
Output is correct |
29 |
Correct |
2 ms |
748 KB |
Output is correct |
30 |
Correct |
2 ms |
748 KB |
Output is correct |
31 |
Correct |
3 ms |
748 KB |
Output is correct |
32 |
Correct |
2 ms |
748 KB |
Output is correct |
33 |
Correct |
1139 ms |
66340 KB |
Output is correct |
34 |
Correct |
1147 ms |
66340 KB |
Output is correct |
35 |
Correct |
1131 ms |
66364 KB |
Output is correct |
36 |
Correct |
1139 ms |
66340 KB |
Output is correct |
37 |
Correct |
1143 ms |
66468 KB |
Output is correct |
38 |
Correct |
1135 ms |
66340 KB |
Output is correct |
39 |
Correct |
1133 ms |
66340 KB |
Output is correct |
40 |
Correct |
1138 ms |
66340 KB |
Output is correct |
41 |
Correct |
1127 ms |
66340 KB |
Output is correct |
42 |
Correct |
1138 ms |
66488 KB |
Output is correct |
43 |
Correct |
1124 ms |
66340 KB |
Output is correct |
44 |
Correct |
1113 ms |
66372 KB |
Output is correct |
45 |
Correct |
1111 ms |
66340 KB |
Output is correct |
46 |
Correct |
1119 ms |
66340 KB |
Output is correct |
47 |
Correct |
1113 ms |
66468 KB |
Output is correct |
48 |
Correct |
1111 ms |
66468 KB |
Output is correct |
49 |
Correct |
1114 ms |
66340 KB |
Output is correct |
50 |
Correct |
1113 ms |
66468 KB |
Output is correct |
51 |
Correct |
1133 ms |
66340 KB |
Output is correct |
52 |
Correct |
1126 ms |
66340 KB |
Output is correct |
53 |
Correct |
1122 ms |
66340 KB |
Output is correct |
54 |
Correct |
1112 ms |
66340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
748 KB |
Output is correct |
2 |
Correct |
3 ms |
748 KB |
Output is correct |
3 |
Correct |
3 ms |
748 KB |
Output is correct |
4 |
Correct |
3 ms |
748 KB |
Output is correct |
5 |
Correct |
2 ms |
748 KB |
Output is correct |
6 |
Correct |
3 ms |
748 KB |
Output is correct |
7 |
Correct |
3 ms |
748 KB |
Output is correct |
8 |
Correct |
4 ms |
748 KB |
Output is correct |
9 |
Correct |
3 ms |
748 KB |
Output is correct |
10 |
Correct |
3 ms |
876 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
0 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
384 KB |
Output is correct |
14 |
Correct |
1 ms |
364 KB |
Output is correct |
15 |
Correct |
1 ms |
364 KB |
Output is correct |
16 |
Correct |
1 ms |
364 KB |
Output is correct |
17 |
Correct |
0 ms |
364 KB |
Output is correct |
18 |
Correct |
1 ms |
384 KB |
Output is correct |
19 |
Correct |
1 ms |
364 KB |
Output is correct |
20 |
Correct |
1 ms |
364 KB |
Output is correct |
21 |
Correct |
2 ms |
748 KB |
Output is correct |
22 |
Correct |
2 ms |
748 KB |
Output is correct |
23 |
Correct |
2 ms |
748 KB |
Output is correct |
24 |
Correct |
2 ms |
748 KB |
Output is correct |
25 |
Correct |
2 ms |
748 KB |
Output is correct |
26 |
Correct |
2 ms |
748 KB |
Output is correct |
27 |
Correct |
2 ms |
748 KB |
Output is correct |
28 |
Correct |
3 ms |
748 KB |
Output is correct |
29 |
Correct |
2 ms |
748 KB |
Output is correct |
30 |
Correct |
2 ms |
748 KB |
Output is correct |
31 |
Correct |
3 ms |
748 KB |
Output is correct |
32 |
Correct |
2 ms |
748 KB |
Output is correct |
33 |
Correct |
1139 ms |
66340 KB |
Output is correct |
34 |
Correct |
1147 ms |
66340 KB |
Output is correct |
35 |
Correct |
1131 ms |
66364 KB |
Output is correct |
36 |
Correct |
1139 ms |
66340 KB |
Output is correct |
37 |
Correct |
1143 ms |
66468 KB |
Output is correct |
38 |
Correct |
1135 ms |
66340 KB |
Output is correct |
39 |
Correct |
1133 ms |
66340 KB |
Output is correct |
40 |
Correct |
1138 ms |
66340 KB |
Output is correct |
41 |
Correct |
1127 ms |
66340 KB |
Output is correct |
42 |
Correct |
1138 ms |
66488 KB |
Output is correct |
43 |
Correct |
1124 ms |
66340 KB |
Output is correct |
44 |
Correct |
1113 ms |
66372 KB |
Output is correct |
45 |
Correct |
1111 ms |
66340 KB |
Output is correct |
46 |
Correct |
1119 ms |
66340 KB |
Output is correct |
47 |
Correct |
1113 ms |
66468 KB |
Output is correct |
48 |
Correct |
1111 ms |
66468 KB |
Output is correct |
49 |
Correct |
1114 ms |
66340 KB |
Output is correct |
50 |
Correct |
1113 ms |
66468 KB |
Output is correct |
51 |
Correct |
1133 ms |
66340 KB |
Output is correct |
52 |
Correct |
1126 ms |
66340 KB |
Output is correct |
53 |
Correct |
1122 ms |
66340 KB |
Output is correct |
54 |
Correct |
1112 ms |
66340 KB |
Output is correct |
55 |
Correct |
1140 ms |
66520 KB |
Output is correct |
56 |
Correct |
1125 ms |
66340 KB |
Output is correct |
57 |
Correct |
1144 ms |
66340 KB |
Output is correct |
58 |
Correct |
1140 ms |
66468 KB |
Output is correct |
59 |
Correct |
1143 ms |
66340 KB |
Output is correct |
60 |
Correct |
1137 ms |
66468 KB |
Output is correct |
61 |
Correct |
1138 ms |
66340 KB |
Output is correct |
62 |
Correct |
1141 ms |
66596 KB |
Output is correct |
63 |
Correct |
1141 ms |
66340 KB |
Output is correct |
64 |
Correct |
1138 ms |
66340 KB |
Output is correct |
65 |
Correct |
1146 ms |
66340 KB |
Output is correct |
66 |
Correct |
1132 ms |
66340 KB |
Output is correct |
67 |
Correct |
1135 ms |
66340 KB |
Output is correct |
68 |
Correct |
1139 ms |
66340 KB |
Output is correct |
69 |
Correct |
1133 ms |
66520 KB |
Output is correct |
70 |
Correct |
1126 ms |
66340 KB |
Output is correct |
71 |
Correct |
1129 ms |
66340 KB |
Output is correct |
72 |
Correct |
1144 ms |
66340 KB |
Output is correct |
73 |
Correct |
1122 ms |
66340 KB |
Output is correct |
74 |
Correct |
1133 ms |
66340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
748 KB |
Output is correct |
2 |
Correct |
2 ms |
748 KB |
Output is correct |
3 |
Correct |
2 ms |
748 KB |
Output is correct |
4 |
Correct |
2 ms |
748 KB |
Output is correct |
5 |
Correct |
2 ms |
748 KB |
Output is correct |
6 |
Correct |
3 ms |
748 KB |
Output is correct |
7 |
Correct |
2 ms |
748 KB |
Output is correct |
8 |
Correct |
2 ms |
748 KB |
Output is correct |
9 |
Correct |
2 ms |
748 KB |
Output is correct |
10 |
Correct |
2 ms |
748 KB |
Output is correct |
11 |
Correct |
0 ms |
364 KB |
Output is correct |
12 |
Correct |
0 ms |
364 KB |
Output is correct |
13 |
Correct |
0 ms |
364 KB |
Output is correct |
14 |
Correct |
1 ms |
364 KB |
Output is correct |
15 |
Correct |
1 ms |
364 KB |
Output is correct |
16 |
Correct |
2 ms |
748 KB |
Output is correct |
17 |
Correct |
3 ms |
748 KB |
Output is correct |
18 |
Correct |
3 ms |
748 KB |
Output is correct |
19 |
Correct |
3 ms |
748 KB |
Output is correct |
20 |
Correct |
2 ms |
748 KB |
Output is correct |
21 |
Correct |
3 ms |
748 KB |
Output is correct |
22 |
Correct |
3 ms |
748 KB |
Output is correct |
23 |
Correct |
4 ms |
748 KB |
Output is correct |
24 |
Correct |
3 ms |
748 KB |
Output is correct |
25 |
Correct |
3 ms |
876 KB |
Output is correct |
26 |
Correct |
1 ms |
364 KB |
Output is correct |
27 |
Correct |
0 ms |
364 KB |
Output is correct |
28 |
Correct |
1 ms |
384 KB |
Output is correct |
29 |
Correct |
1 ms |
364 KB |
Output is correct |
30 |
Correct |
1 ms |
364 KB |
Output is correct |
31 |
Correct |
1 ms |
364 KB |
Output is correct |
32 |
Correct |
0 ms |
364 KB |
Output is correct |
33 |
Correct |
1 ms |
384 KB |
Output is correct |
34 |
Correct |
1 ms |
364 KB |
Output is correct |
35 |
Correct |
1 ms |
364 KB |
Output is correct |
36 |
Correct |
2 ms |
748 KB |
Output is correct |
37 |
Correct |
2 ms |
748 KB |
Output is correct |
38 |
Correct |
2 ms |
748 KB |
Output is correct |
39 |
Correct |
2 ms |
748 KB |
Output is correct |
40 |
Correct |
2 ms |
748 KB |
Output is correct |
41 |
Correct |
2 ms |
748 KB |
Output is correct |
42 |
Correct |
2 ms |
748 KB |
Output is correct |
43 |
Correct |
3 ms |
748 KB |
Output is correct |
44 |
Correct |
2 ms |
748 KB |
Output is correct |
45 |
Correct |
2 ms |
748 KB |
Output is correct |
46 |
Correct |
3 ms |
748 KB |
Output is correct |
47 |
Correct |
2 ms |
748 KB |
Output is correct |
48 |
Correct |
1139 ms |
66340 KB |
Output is correct |
49 |
Correct |
1147 ms |
66340 KB |
Output is correct |
50 |
Correct |
1131 ms |
66364 KB |
Output is correct |
51 |
Correct |
1139 ms |
66340 KB |
Output is correct |
52 |
Correct |
1143 ms |
66468 KB |
Output is correct |
53 |
Correct |
1135 ms |
66340 KB |
Output is correct |
54 |
Correct |
1133 ms |
66340 KB |
Output is correct |
55 |
Correct |
1138 ms |
66340 KB |
Output is correct |
56 |
Correct |
1127 ms |
66340 KB |
Output is correct |
57 |
Correct |
1138 ms |
66488 KB |
Output is correct |
58 |
Correct |
1124 ms |
66340 KB |
Output is correct |
59 |
Correct |
1113 ms |
66372 KB |
Output is correct |
60 |
Correct |
1111 ms |
66340 KB |
Output is correct |
61 |
Correct |
1119 ms |
66340 KB |
Output is correct |
62 |
Correct |
1113 ms |
66468 KB |
Output is correct |
63 |
Correct |
1111 ms |
66468 KB |
Output is correct |
64 |
Correct |
1114 ms |
66340 KB |
Output is correct |
65 |
Correct |
1113 ms |
66468 KB |
Output is correct |
66 |
Correct |
1133 ms |
66340 KB |
Output is correct |
67 |
Correct |
1126 ms |
66340 KB |
Output is correct |
68 |
Correct |
1122 ms |
66340 KB |
Output is correct |
69 |
Correct |
1112 ms |
66340 KB |
Output is correct |
70 |
Correct |
1140 ms |
66520 KB |
Output is correct |
71 |
Correct |
1125 ms |
66340 KB |
Output is correct |
72 |
Correct |
1144 ms |
66340 KB |
Output is correct |
73 |
Correct |
1140 ms |
66468 KB |
Output is correct |
74 |
Correct |
1143 ms |
66340 KB |
Output is correct |
75 |
Correct |
1137 ms |
66468 KB |
Output is correct |
76 |
Correct |
1138 ms |
66340 KB |
Output is correct |
77 |
Correct |
1141 ms |
66596 KB |
Output is correct |
78 |
Correct |
1141 ms |
66340 KB |
Output is correct |
79 |
Correct |
1138 ms |
66340 KB |
Output is correct |
80 |
Correct |
1146 ms |
66340 KB |
Output is correct |
81 |
Correct |
1132 ms |
66340 KB |
Output is correct |
82 |
Correct |
1135 ms |
66340 KB |
Output is correct |
83 |
Correct |
1139 ms |
66340 KB |
Output is correct |
84 |
Correct |
1133 ms |
66520 KB |
Output is correct |
85 |
Correct |
1126 ms |
66340 KB |
Output is correct |
86 |
Correct |
1129 ms |
66340 KB |
Output is correct |
87 |
Correct |
1144 ms |
66340 KB |
Output is correct |
88 |
Correct |
1122 ms |
66340 KB |
Output is correct |
89 |
Correct |
1133 ms |
66340 KB |
Output is correct |
90 |
Correct |
1135 ms |
66380 KB |
Output is correct |
91 |
Correct |
1135 ms |
66340 KB |
Output is correct |
92 |
Correct |
1139 ms |
66472 KB |
Output is correct |
93 |
Correct |
1133 ms |
66340 KB |
Output is correct |
94 |
Correct |
1120 ms |
66596 KB |
Output is correct |
95 |
Correct |
1137 ms |
66468 KB |
Output is correct |
96 |
Correct |
1131 ms |
66488 KB |
Output is correct |
97 |
Correct |
1142 ms |
66340 KB |
Output is correct |
98 |
Correct |
1131 ms |
66340 KB |
Output is correct |
99 |
Correct |
1127 ms |
66340 KB |
Output is correct |
100 |
Incorrect |
1004 ms |
66340 KB |
Output isn't correct |
101 |
Halted |
0 ms |
0 KB |
- |