Submission #202155

#TimeUsernameProblemLanguageResultExecution timeMemory
202155SegtreeBulldozer (JOI17_bulldozer)C++14
20 / 100
8 ms760 KiB
#include<iostream> #include<algorithm> #include<vector> #include<queue> #include<set> #include<complex> #include<math.h> #include<unordered_set> #include<unordered_map> 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=0,rui=0,res=0; rep(i,n){ rui+=dat[i]; chmax(res,rui-mi); chmin(mi,rui); } //rep(i,n)cout<<dat[i]<<" ";cout<<":"<<res<<endl; 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); upd(pl[a],w[b]); upd(pl[b],w[a]); 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]); } } rep(i,n){ upd(i,w[i]); 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 (stderr)

bulldozer.cpp: In function 'int main()':
bulldozer.cpp:18:31: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define rep(i,n) for(int i=0;i<n;i++)
bulldozer.cpp:86:9:
     rep(i,Q.size()){
         ~~~~~~~~~~             
bulldozer.cpp:86:5: note: in expansion of macro 'rep'
     rep(i,Q.size()){
     ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...