#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef complex<long double> C;
#define chmax(a,b) a=max(a,b)
#define chmin(a,b) a=min(a,b)
#define all(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod
#define PI acosl(-1)
#define N 110
ll n,x[N],y[N],w[N];
ll dat[N];
void upd(ll i,ll x){
dat[i]=x;
}
ll rsm(){
ll mi=dat[0],res=0;
rep(i,n){
chmin(mi,dat[i+1]);
chmax(res,dat[i+1]-mi);
}
return res;
}
ll pl[N];
ll swp(int a,int b){//cout<<"swp"<<w[a]<<" "<<w[b]<<endl;
if(pl[a]>pl[b])swap(a,b);
assert(pl[a]+1==pl[b]);
upd(pl[a]+1,dat[pl[a]]+w[b]);
swap(pl[a],pl[b]);
return rsm();
}
struct qry{
ld arg;
ll a,b;
bool operator<(const qry&key)const{
return this->arg<key.arg;
}
};
int main(){
cin>>n;
rep(i,n){
cin>>x[i]>>y[i]>>w[i];
}
rep(i,n)rep(j,n-1){
bool sw=0;
if(y[j]!=y[j+1])sw=y[j]>y[j+1];
else if(x[j]!=x[j+1])sw=x[j]<x[j+1];
if(sw){
swap(x[j],x[j+1]);
swap(y[j],y[j+1]);
swap(w[j],w[j+1]);
}
}
ll rui=0;
upd(0,0);
rep(i,n){
rui+=w[i];
upd(i+1,rui);
pl[i]=i;
}
vector<qry> Q;
rep(i,n)rep(j,i){
ld vl=atan2(y[i]-y[j],x[i]-x[j]);
ld vr=atan2(y[j]-y[i],x[j]-x[i]);
//cout<<"atan"<<w[i]<<" "<<w[j]<<" "<<vl<<" "<<vr<<endl;
Q.push_back((struct qry){max(vl,vr),i,j});
}
sort(all(Q));
ll ans=rsm();
rep(i,Q.size()){
chmax(ans,swp(Q[i].a,Q[i].b));
}
cout<<ans<<endl;
}
Compilation message
bulldozer.cpp: In function 'int main()':
bulldozer.cpp:10:31: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
#define rep(i,n) for(int i=0;i<n;i++)
bulldozer.cpp:79:9:
rep(i,Q.size()){
~~~~~~~~~~
bulldozer.cpp:79:5: note: in expansion of macro 'rep'
rep(i,Q.size()){
^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
6 ms |
1008 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
760 KB |
Output is correct |
2 |
Correct |
7 ms |
760 KB |
Output is correct |
3 |
Correct |
7 ms |
760 KB |
Output is correct |
4 |
Correct |
7 ms |
760 KB |
Output is correct |
5 |
Correct |
7 ms |
760 KB |
Output is correct |
6 |
Correct |
7 ms |
760 KB |
Output is correct |
7 |
Correct |
7 ms |
760 KB |
Output is correct |
8 |
Correct |
7 ms |
636 KB |
Output is correct |
9 |
Correct |
7 ms |
764 KB |
Output is correct |
10 |
Correct |
7 ms |
760 KB |
Output is correct |
11 |
Correct |
5 ms |
256 KB |
Output is correct |
12 |
Correct |
5 ms |
256 KB |
Output is correct |
13 |
Correct |
5 ms |
256 KB |
Output is correct |
14 |
Correct |
5 ms |
256 KB |
Output is correct |
15 |
Correct |
5 ms |
380 KB |
Output is correct |
16 |
Correct |
5 ms |
256 KB |
Output is correct |
17 |
Correct |
5 ms |
376 KB |
Output is correct |
18 |
Correct |
5 ms |
256 KB |
Output is correct |
19 |
Correct |
5 ms |
256 KB |
Output is correct |
20 |
Correct |
5 ms |
256 KB |
Output is correct |
21 |
Correct |
7 ms |
760 KB |
Output is correct |
22 |
Correct |
8 ms |
760 KB |
Output is correct |
23 |
Correct |
7 ms |
760 KB |
Output is correct |
24 |
Correct |
7 ms |
760 KB |
Output is correct |
25 |
Correct |
7 ms |
760 KB |
Output is correct |
26 |
Correct |
7 ms |
760 KB |
Output is correct |
27 |
Correct |
7 ms |
760 KB |
Output is correct |
28 |
Correct |
7 ms |
760 KB |
Output is correct |
29 |
Correct |
7 ms |
760 KB |
Output is correct |
30 |
Correct |
7 ms |
760 KB |
Output is correct |
31 |
Correct |
7 ms |
760 KB |
Output is correct |
32 |
Correct |
7 ms |
764 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
760 KB |
Output is correct |
2 |
Correct |
7 ms |
760 KB |
Output is correct |
3 |
Correct |
7 ms |
760 KB |
Output is correct |
4 |
Correct |
7 ms |
760 KB |
Output is correct |
5 |
Correct |
7 ms |
760 KB |
Output is correct |
6 |
Correct |
7 ms |
760 KB |
Output is correct |
7 |
Correct |
7 ms |
760 KB |
Output is correct |
8 |
Correct |
7 ms |
636 KB |
Output is correct |
9 |
Correct |
7 ms |
764 KB |
Output is correct |
10 |
Correct |
7 ms |
760 KB |
Output is correct |
11 |
Correct |
5 ms |
256 KB |
Output is correct |
12 |
Correct |
5 ms |
256 KB |
Output is correct |
13 |
Correct |
5 ms |
256 KB |
Output is correct |
14 |
Correct |
5 ms |
256 KB |
Output is correct |
15 |
Correct |
5 ms |
380 KB |
Output is correct |
16 |
Correct |
5 ms |
256 KB |
Output is correct |
17 |
Correct |
5 ms |
376 KB |
Output is correct |
18 |
Correct |
5 ms |
256 KB |
Output is correct |
19 |
Correct |
5 ms |
256 KB |
Output is correct |
20 |
Correct |
5 ms |
256 KB |
Output is correct |
21 |
Correct |
7 ms |
760 KB |
Output is correct |
22 |
Correct |
8 ms |
760 KB |
Output is correct |
23 |
Correct |
7 ms |
760 KB |
Output is correct |
24 |
Correct |
7 ms |
760 KB |
Output is correct |
25 |
Correct |
7 ms |
760 KB |
Output is correct |
26 |
Correct |
7 ms |
760 KB |
Output is correct |
27 |
Correct |
7 ms |
760 KB |
Output is correct |
28 |
Correct |
7 ms |
760 KB |
Output is correct |
29 |
Correct |
7 ms |
760 KB |
Output is correct |
30 |
Correct |
7 ms |
760 KB |
Output is correct |
31 |
Correct |
7 ms |
760 KB |
Output is correct |
32 |
Correct |
7 ms |
764 KB |
Output is correct |
33 |
Incorrect |
5 ms |
256 KB |
Output isn't correct |
34 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
760 KB |
Output is correct |
2 |
Correct |
7 ms |
760 KB |
Output is correct |
3 |
Correct |
7 ms |
760 KB |
Output is correct |
4 |
Correct |
7 ms |
760 KB |
Output is correct |
5 |
Correct |
7 ms |
760 KB |
Output is correct |
6 |
Correct |
7 ms |
760 KB |
Output is correct |
7 |
Correct |
7 ms |
760 KB |
Output is correct |
8 |
Correct |
7 ms |
636 KB |
Output is correct |
9 |
Correct |
7 ms |
764 KB |
Output is correct |
10 |
Correct |
7 ms |
760 KB |
Output is correct |
11 |
Correct |
5 ms |
256 KB |
Output is correct |
12 |
Correct |
5 ms |
256 KB |
Output is correct |
13 |
Correct |
5 ms |
256 KB |
Output is correct |
14 |
Correct |
5 ms |
256 KB |
Output is correct |
15 |
Correct |
5 ms |
380 KB |
Output is correct |
16 |
Correct |
5 ms |
256 KB |
Output is correct |
17 |
Correct |
5 ms |
376 KB |
Output is correct |
18 |
Correct |
5 ms |
256 KB |
Output is correct |
19 |
Correct |
5 ms |
256 KB |
Output is correct |
20 |
Correct |
5 ms |
256 KB |
Output is correct |
21 |
Correct |
7 ms |
760 KB |
Output is correct |
22 |
Correct |
8 ms |
760 KB |
Output is correct |
23 |
Correct |
7 ms |
760 KB |
Output is correct |
24 |
Correct |
7 ms |
760 KB |
Output is correct |
25 |
Correct |
7 ms |
760 KB |
Output is correct |
26 |
Correct |
7 ms |
760 KB |
Output is correct |
27 |
Correct |
7 ms |
760 KB |
Output is correct |
28 |
Correct |
7 ms |
760 KB |
Output is correct |
29 |
Correct |
7 ms |
760 KB |
Output is correct |
30 |
Correct |
7 ms |
760 KB |
Output is correct |
31 |
Correct |
7 ms |
760 KB |
Output is correct |
32 |
Correct |
7 ms |
764 KB |
Output is correct |
33 |
Incorrect |
5 ms |
256 KB |
Output isn't correct |
34 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
6 ms |
1008 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |