Submission #1077816

#TimeUsernameProblemLanguageResultExecution timeMemory
1077816vnm06Bulldozer (JOI17_bulldozer)C++14
0 / 100
3 ms780 KiB
#include<bits/stdc++.h> #define endl '\n' using namespace std; struct point { long long x, y, val, nom; point() {} point(long long a, long long b, long long c, long long d) { x=a; y=b; val=c; nom=d; } }; bool operator<(point p, point q) { if(p.x==q.x) return p.y<q.y; return p.x<q.x; } struct line { point a, b; line() {} line(point p, point q) { a=p; b=q; } }; bool cmp(line p, line q) { if(p.a.x==p.b.x) return 1; if(q.a.x==q.b.x) return 1; return ((p.b.y-p.a.y) * (q.b.x-q.a.x)) < ((q.b.y-q.a.y) * (p.b.x-p.a.x)); } long long n, brl=0; long long pos[2005]; point P[2005]; line L[4000005]; long long ans=0; long long A[2005]; void solve() { long long res=0; for(long long i=0; i<n; i++) { res+=A[i]; if(res<0) res=0; if(res>ans) ans=res; } } int main() { /// ios::sync_with_stdio(0); ///cin.tie(0); /// cout.tie(0); cin>>n; for(long long i=0; i<n; i++) cin>>P[i].x>>P[i].y>>P[i].val; sort(P, P+n); for(long long i=0; i<n; i++) P[i].nom=i; for(long long i=0; i<n; i++) { A[i]=P[i].val; pos[i]=i; for(long long j=i+1; j<n; j++) { L[brl]=line(P[i], P[j]); ///cout<<L[brl].a.x<<" "<<L[brl].a.y<<" "<<L[brl].b.x<<" "<<L[brl].b.y<<"\n"; brl++; } } ///cout<<brl<<endl; sort(L, L+brl, cmp); for(long long i=0; i<brl; i++) { solve(); point t1=L[i].a, t2=L[i].b; swap(A[pos[t1.nom]], A[pos[t2.nom]]); swap(pos[t1.nom], pos[t2.nom]); } cout<<ans<<endl; return 0; }
#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...