Submission #64269

# Submission time Handle Problem Language Result Execution time Memory
64269 2018-08-03T20:20:08 Z reality Bulldozer (JOI17_bulldozer) C++17
0 / 100
4 ms 812 KB
#include "bits/stdc++.h"
using namespace std;
#define fi first
#define se second
#define ll long long
#define dbg(v) cerr<<#v<<" = "<<v<<'\n'
#define vi vector<int>
#define vl vector <ll>
#define pii pair<int,int>
#define mp make_pair
#define db long double
#define pb push_back
#define all(s) s.begin(),s.end()
template < class T > ostream& operator<<(ostream& stream, const vector<T> v){ stream << "[ "; for (int i=0; i<(int)v.size(); i++) stream << v[i] << " "; stream << "]"; return stream;}
template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;}
template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;}
struct fr {
    ll fi,se;
    fr(void) {
        fi = se = 0;
    }
    fr(ll aa,ll bb) {
        if (aa < 0 || (!aa && bb < 0))
            aa *= -1,bb *= -1;
        fi = aa;
        se = bb;
    }
};
bool operator == (fr a,fr b) {
    return a.fi * b.se == a.se * b.fi;
}
bool operator < (fr a,fr b) {
    return a.fi * b.se < a.se * b.fi;
}
bool operator != (fr a,fr b) {
    return !(a == b);
}
struct st {
    ll ss,ls,rs,as;
    st(void) {
        ss = ls = rs = as;
    }
    st(ll x) {
        ss = x;
        ls = rs = as = max(0ll,x);
    }
};
st operator + (st a,st b) {
    st c;
    c.ss = a.ss + b.ss;
    c.ls = max(a.ls,a.ss + b.ls);
    c.rs = max(b.rs,b.ss + a.rs);
    c.as = max({a.as,b.as,a.rs + b.ls});
    return c;
}
st t[4096];
void update(int l,int r,int pos,ll v,int node) {
    if (l == r)
        t[node] = st(v);
    else {
        int m = (l + r) / 2;
        if (pos <= m)
            update(l,m,pos,v,node * 2);
        else
            update(m+1,r,pos,v,node * 2 + 1);
        t[node] = t[node * 2] + t[node * 2 + 1];
    }
}
int main(void) {
    int n;
    cin>>n;
    vector < pair < pii , ll > > p(n);
    for (auto & it : p)
        cin>>it.fi.fi>>it.fi.se>>it.se;
    sort(all(p));
    vector < pair < fr , pii > > sw;
    for (int i = 0;i < n;++i)
        for (int j = i + 1;j < n;++j)
            sw.pb(mp(fr(p[i].fi.fi - p[j].fi.fi,p[i].fi.se - p[j].fi.se),mp(i,j)));
    vi q(n);
    for (int i = 0;i < n;++i)
        q[i] = i,update(0,n - 1,i,p[i].se,1);
    sort(all(sw),[&](auto a,auto b) {
            if (a.fi != b.fi)
                return b.fi < a.fi;
            return a.se < b.se;
        });
    int sz = sw.size();
    ll answer = 0;
    for (int i = 0,j = 0;i < sz;i = j) {
        while (j < sz && sw[i].fi == sw[j].fi) {
            int pi = sw[j].se.fi;
            int pj = sw[j].se.se;
            swap(q[pi],q[pj]);
            update(0,n - 1,q[pi],p[pi].se,1);
            update(0,n - 1,q[pj],p[pj].se,1);
            ++j;
        }
        smax(answer,t[1].as);
    }
    cout << answer << '\n';
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 768 KB Output is correct
2 Correct 4 ms 768 KB Output is correct
3 Correct 3 ms 768 KB Output is correct
4 Correct 4 ms 768 KB Output is correct
5 Correct 4 ms 768 KB Output is correct
6 Correct 0 ms 768 KB Output is correct
7 Correct 3 ms 768 KB Output is correct
8 Correct 3 ms 768 KB Output is correct
9 Correct 3 ms 748 KB Output is correct
10 Correct 3 ms 768 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Incorrect 2 ms 384 KB Output isn't correct
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 812 KB Output is correct
2 Correct 4 ms 768 KB Output is correct
3 Correct 4 ms 768 KB Output is correct
4 Correct 4 ms 768 KB Output is correct
5 Correct 4 ms 768 KB Output is correct
6 Correct 4 ms 768 KB Output is correct
7 Correct 3 ms 768 KB Output is correct
8 Correct 4 ms 768 KB Output is correct
9 Correct 4 ms 768 KB Output is correct
10 Correct 3 ms 768 KB Output is correct
11 Correct 2 ms 512 KB Output is correct
12 Incorrect 2 ms 384 KB Output isn't correct
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 812 KB Output is correct
2 Correct 4 ms 768 KB Output is correct
3 Correct 4 ms 768 KB Output is correct
4 Correct 4 ms 768 KB Output is correct
5 Correct 4 ms 768 KB Output is correct
6 Correct 4 ms 768 KB Output is correct
7 Correct 3 ms 768 KB Output is correct
8 Correct 4 ms 768 KB Output is correct
9 Correct 4 ms 768 KB Output is correct
10 Correct 3 ms 768 KB Output is correct
11 Correct 2 ms 512 KB Output is correct
12 Incorrect 2 ms 384 KB Output isn't correct
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 812 KB Output is correct
2 Correct 4 ms 768 KB Output is correct
3 Correct 4 ms 768 KB Output is correct
4 Correct 4 ms 768 KB Output is correct
5 Correct 4 ms 768 KB Output is correct
6 Correct 4 ms 768 KB Output is correct
7 Correct 3 ms 768 KB Output is correct
8 Correct 4 ms 768 KB Output is correct
9 Correct 4 ms 768 KB Output is correct
10 Correct 3 ms 768 KB Output is correct
11 Correct 2 ms 512 KB Output is correct
12 Incorrect 2 ms 384 KB Output isn't correct
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 768 KB Output is correct
2 Correct 4 ms 768 KB Output is correct
3 Correct 3 ms 768 KB Output is correct
4 Correct 4 ms 768 KB Output is correct
5 Correct 4 ms 768 KB Output is correct
6 Correct 0 ms 768 KB Output is correct
7 Correct 3 ms 768 KB Output is correct
8 Correct 3 ms 768 KB Output is correct
9 Correct 3 ms 748 KB Output is correct
10 Correct 3 ms 768 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Incorrect 2 ms 384 KB Output isn't correct
13 Halted 0 ms 0 KB -