제출 #1158970

#제출 시각아이디문제언어결과실행 시간메모리
1158970Zero_OPBulldozer (JOI17_bulldozer)C++20
0 / 100
18 ms328 KiB
#include <bits/stdc++.h> using namespace std; #define FOR(i, l, r) for(int i = (l); i < (r); ++i) #define ROF(i, r, l) for(int i = (r) - 1; i >= (l); --i) #define mp make_pair #define mt make_tuple #define ff first #define ss second #define all(v) begin(v), end(v) #define rall(v) rbegin(v), rend(v) #define sz(v) (int)v.size() #define compact(v) v.erase(unique(all(v)), end(v)) #define pb push_back #define eb emplace_back #define dbg(x) "[" #x " = " << (x) << "]" #define readFile(task) freopen(task, "r", stdin) #define writeFile(task) freopen(task, "w", stdout) template<typename T> bool minimize(T& a, const T& b){ if(a > b) return a = b, true; return false; } template<typename T> bool maximize(T& a, const T& b){ if(a < b) return a = b, true; return false; } using ll = long long; using db = double; using ull = unsigned long long; using ld = long double; using pi = pair<int, int>; using pl = pair<ll, ll>; using pd = pair<db, db>; using vi = vector<int>; using vl = vector<ll>; using vd = vector<db>; using vb = vector<bool>; using vpi = vector<pi>; using vpl = vector<pl>; using vvi = vector<vi>; using vvl = vector<vl>; void setIO(){ ios_base::sync_with_stdio(0); cin.tie(0); #ifdef LOCAL readFile("task.inp"); writeFile("task.out"); #endif // LOCAL } struct point{ ll x, y; point(ll x = 0, ll y = 0) : x(x), y(y) {} friend bool operator != (const point& a, const point& b){ return a.x != b.x || a.y != b.y; } friend bool operator == (const point& a, const point& b){ return a.x == b.x && a.y == b.y; } point& operator += (const point& p){ x += p.x; y += p.y; return *this; } point& operator -= (const point& p){ x -= p.x; y -= p.y; return *this; } friend point operator + (point a, const point& b){ return a += b; } friend point operator - (point a, const point& b){ return a -= b; } friend istream& operator >> (istream& in, point& p){ return in >> p.x >> p.y; } friend ostream& operator << (ostream& out, const point& p){ return out << '(' << p.x << ',' << p.y << ')'; } }; ll dot(const point& a, const point& b){ return a.x * b.x + a.y * b.y; } //u . v ll cross(const point& a, const point& b){ return a.x * b.y - a.y * b.x; } //u x v ll dot3(const point& a, point b, point c){ b -= a; c -= a; return dot(b, c); } //AB . AC ll cross3(const point& a, point b, point c){ b -= a; c -= a; return cross(b, c); } //AB x AC struct fraction{ ll a, b; fraction(ll a, ll b) : a(a), b(b) { ll g = __gcd(abs(a), abs(b)); if(g > 0) a /= g, b /= g; if(b < 0) a = -a, b = -b; } }; struct line{ ll a, b, c; //ax + by + c = 0 line(const point& A, const point& B){ a = B.y - A.y; b = A.x - B.x; c = cross(B, A); assert(evaluate(A) == 0); assert(evaluate(B) == 0); } ll evaluate(const point& p){ return a * p.x + b * p.y + c; } }; int main(){ setIO(); int N; cin >> N; vector<point> pts(N); vi earn(N); FOR(i, 0, N) cin >> pts[i] >> earn[i]; ll ans = max(0, *max_element(all(earn))); FOR(i, 0, N){ FOR(j, i+1, N){ line D(pts[i], pts[j]); vector<pl> dists; FOR(k, 0, N){ dists.pb(mp(D.evaluate(pts[k]), earn[k])); } sort(all(dists)); ll pref = 0, min_pref = 0; FOR(p, 0, N){ ll sum = dists[p].ss; while(p+1 < N && dists[p+1].ff == dists[p].ff){ ++p; sum += dists[p].ss; } pref += sum; maximize(ans, pref - min_pref); minimize(min_pref, pref); } } } cout << ans << '\n'; 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...