제출 #206114

#제출 시각아이디문제언어결과실행 시간메모리
206114TAISA_Bulldozer (JOI17_bulldozer)C++14
55 / 100
1393 ms128212 KiB
#include <bits/stdc++.h> #define all(v) v.begin(),v.end() #define eb emplace_back using namespace std; using ll=long long; using P=pair<int,int>; using C=complex<double>; void chmax(ll &a,ll b){a=max(a,b);} void chmin(ll &a,ll b){a=min(a,b);} struct segtree{ struct T{ ll l,r,sum,val; }; T merge(T &a,T &b){ T res; res.l=max(a.l,a.sum+b.l); res.r=max(b.r,a.r+b.sum); res.sum=a.sum+b.sum; res.val=max({a.val,b.val,a.r+b.l}); return res; } int n; vector<T> dat; segtree(int n_){ n=1; while(n<n_)n<<=1; dat.resize(2*n,T{0,0,0,0}); } void upd(int k,ll x){ T to=T{max(x,0LL),max(x,0LL),x,max(x,0LL)}; k+=n; dat[k]=to; k>>=1; while(k>0){ dat[k]=merge(dat[k<<1],dat[k<<1|1]); k>>=1; } } inline ll get(){ return dat[1].val; } }; const long double eps=1e-50; bool equal(long double a,long double b){return a-eps<=b&&b<=a+eps;} int main(){ ios::sync_with_stdio(0); cin.tie(0); int n;cin>>n; vector<long double> x(n),y(n); vector<ll> w(n); vector<pair<long double,P>> v; vector<pair<P,int>> ps(n); for(int i=0;i<n;i++){ cin>>x[i]>>y[i]>>w[i]; ps[i]=make_pair(P(y[i],x[i]),i); } for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ if(i==j)continue; long double t=atan2l(y[j]-y[i],x[j]-x[i]); if(t>=0){ v.eb(t,P(i,j)); } } } sort(all(v)); sort(all(ps)); reverse(all(ps)); segtree seg(n); vector<int> pos(n),a(n); for(int i=0;i<n;i++){ seg.upd(i,w[ps[i].second]); pos[ps[i].second]=i; a[i]=ps[i].second; } ll res=seg.get(); set<int> st; for(int i=0;i<v.size();i++){ int l=v[i].second.first,r=v[i].second.second; swap(pos[l],pos[r]); swap(a[pos[l]],a[pos[r]]); seg.upd(pos[l],w[l]); seg.upd(pos[r],w[r]); st.insert(l); st.insert(r); if(i+1<v.size()&&equal(v[i].first,v[i+1].first))continue; /*cout<<l<<" "<<r<<" "<<seg.get()<<endl; for(int j=0;j<n;j++)cout<<a[j]<<" "; cout<<endl;*/ assert(st.size()==2); st.clear(); chmax(res,seg.get()); } cout<<res<<'\n'; }

컴파일 시 표준 에러 (stderr) 메시지

bulldozer.cpp: In function 'int main()':
bulldozer.cpp:78:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<v.size();i++){
              ~^~~~~~~~~
bulldozer.cpp:86:9: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if(i+1<v.size()&&equal(v[i].first,v[i+1].first))continue;
      ~~~^~~~~~~~~
#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...