답안 #122048

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
122048 2019-06-27T13:11:06 Z egorlifar Bulldozer (JOI17_bulldozer) C++17
55 / 100
2000 ms 17380 KB
/*
ЗАПУСКАЕМ 
░ГУСЯ░▄▀▀▀▄░РАБОТЯГУ░░
▄███▀░◐░░░▌░░░░░░░
░░░░▌░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░▄▀▒▒▀▀▀▀▄
░░░▐░░░░▐▒▒▒▒▒▒▒▒▀▀▄
░░░▐░░░░▐▄▒▒▒▒▒▒▒▒▒▒▀▄
░░░░▀▄░░░░▀▄▒▒▒▒▒▒▒▒▒▒▀▄
░░░░░░▀▄▄▄▄▄█▄▄▄▄▄▄▄▄▄▄▄▀▄
░░░░░░░░░░░▌▌░▌▌░░░░░
░░░░░░░░░░░▌▌░▌▌░░░░░
░░░░░░░░░▄▄▌▌▄▌▌░░░░░ 
 */
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <chrono>
 
using namespace std;

template<class T1, class T2> inline int chkmin(T1 &x, const T2 &y) {
    if (x > y) {
        x = y;
        return 1;
    }
    else {
        return 0;
    }
}

template<class T1, class T2> inline int chkmax(T1 &x, const T2 &y) {
    if (x < y) {
        x = y;
        return 1;
    }
    else {
        return 0;
    }
}

#define all(c) (c).begin(), (c).end()
#define sz(c) (int)(c).size()
#define mp make_pair
#define pb push_back
#define read(FILENAME) freopen((string(FILENAME) + ".in").c_str(), "r", stdin)
#define write(FILENAME) freopen((string(FILENAME) + ".out").c_str(), "w", stdout);

template<class iterator> void output(iterator begin, iterator end, ostream &out = cerr) {
    while (begin != end) {
        out << (*begin) << " ";
        begin++;
    }
    out << endl;
}


template<class T> void output(const T &x, ostream &out = cerr) {
    output(x.begin(), x.end(), out);
}

void fast_io() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0); 
}
const int MAXN = 3005;


struct point
{
    int x, y, w;
    point(){}
    point(int _x, int _y) {
        x = _x;
        y = _y;
    }
};


bool operator <(const point &a, const point &b) {
    return a.x < b.x || (a.x == b.x && a.y < b.y);
}


point operator -(const point &a, const point &b) {
    return point(a.x - b.x, a.y - b.y);
}


long long vec(const point &a, const point &b) {
    return 1LL * a.x * b.y - 1LL * a.y * b.x;
}


int n;
point p[MAXN];
int pos[MAXN];


long long comp(pair<int, int> a, pair<int, int> b) {
    point g = p[a.second] - p[a.first];
    point g1 = p[b.second] - p[b.first];
    return vec(g, g1);
}


long long comp1(pair<int, int> a, pair<int, int> b) {
    long long ft = comp(a, b);
    if (ft != 0) {
        return ft < 0;
    } else {
        return a < b;
    }
}


struct node {
    long long sum, pref, suf, val;
    node(int x = 0) {
      sum = (long long) x;
      pref = suf = val = (long long)max(x, 0);
    };
   friend node operator + (const node &l, const node &r) {
        node ans;
        ans.sum = l.sum + r.sum;
        ans.pref = max(l.pref, l.sum + r.pref);
        ans.suf = max(r.suf, r.sum + l.suf);
        ans.val = max({l.val, r.val, l.suf + r.pref});
        return ans;
   }
};
 

node t[MAXN * 2]; 

 
void modify(int v, int l, int r, int pos, int val) {
    if (l == r) {
        t[v] = node(val);
        return;
    }
    int mid = (l + r) >> 1;
    if (pos <= mid) {
        modify(v << 1, l, mid, pos, val);
    } else {
        modify(v << 1 | 1, mid + 1, r, pos, val);
    }
    t[v] = t[v << 1] + t[v << 1 | 1];
}

int main() {
    fast_io();
    //read("input");
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> p[i].x >> p[i].y >> p[i].w;  
    }
    sort(p + 1, p + n + 1);
    vector<pair<int, int> > st;
    for (int i = 1; i <= n; i++) {
        for (int j = i + 1; j <= n; j++) {
            st.pb({i, j});
        }
    }
    sort(all(st), comp1);
    for (int i = 1; i <= n; i++) {
        pos[i] = i;
        modify(1, 1, n, i, p[i].w);
    }
    long long ans = t[1].val;
    for (int i = 0; i < sz(st); i++)  {
        vector<pair<int, int> > kek;
        kek.pb(st[i]);
        int j = i + 1;
        while (j < sz(st) && !comp(st[j - 1], st[j])) {
            kek.pb(st[j]);
            j++;
        }
        for (auto x: kek) {
            int a = x.first;
            int b = x.second;
            swap(pos[a], pos[b]);
            modify(1, 1, n, pos[a], p[a].w);
            modify(1, 1, n, pos[b], p[b].w);
        }
        chkmax(ans, t[1].val);
    }
    cout << ans << '\n';
    return 0;
}   
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2035 ms 640 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 640 KB Output is correct
2 Correct 4 ms 640 KB Output is correct
3 Correct 5 ms 640 KB Output is correct
4 Correct 4 ms 640 KB Output is correct
5 Correct 4 ms 640 KB Output is correct
6 Correct 4 ms 640 KB Output is correct
7 Correct 4 ms 640 KB Output is correct
8 Correct 4 ms 640 KB Output is correct
9 Correct 4 ms 640 KB Output is correct
10 Correct 4 ms 640 KB Output is correct
11 Correct 2 ms 512 KB Output is correct
12 Correct 2 ms 512 KB Output is correct
13 Correct 3 ms 512 KB Output is correct
14 Correct 2 ms 512 KB Output is correct
15 Correct 2 ms 512 KB Output is correct
16 Correct 3 ms 512 KB Output is correct
17 Correct 2 ms 512 KB Output is correct
18 Correct 3 ms 512 KB Output is correct
19 Correct 2 ms 512 KB Output is correct
20 Correct 2 ms 512 KB Output is correct
21 Correct 4 ms 572 KB Output is correct
22 Correct 5 ms 640 KB Output is correct
23 Correct 5 ms 640 KB Output is correct
24 Correct 4 ms 640 KB Output is correct
25 Correct 4 ms 640 KB Output is correct
26 Correct 4 ms 640 KB Output is correct
27 Correct 4 ms 640 KB Output is correct
28 Correct 5 ms 640 KB Output is correct
29 Correct 5 ms 640 KB Output is correct
30 Correct 4 ms 640 KB Output is correct
31 Correct 4 ms 640 KB Output is correct
32 Correct 4 ms 640 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 640 KB Output is correct
2 Correct 4 ms 640 KB Output is correct
3 Correct 5 ms 640 KB Output is correct
4 Correct 4 ms 640 KB Output is correct
5 Correct 4 ms 640 KB Output is correct
6 Correct 4 ms 640 KB Output is correct
7 Correct 4 ms 640 KB Output is correct
8 Correct 4 ms 640 KB Output is correct
9 Correct 4 ms 640 KB Output is correct
10 Correct 4 ms 640 KB Output is correct
11 Correct 2 ms 512 KB Output is correct
12 Correct 2 ms 512 KB Output is correct
13 Correct 3 ms 512 KB Output is correct
14 Correct 2 ms 512 KB Output is correct
15 Correct 2 ms 512 KB Output is correct
16 Correct 3 ms 512 KB Output is correct
17 Correct 2 ms 512 KB Output is correct
18 Correct 3 ms 512 KB Output is correct
19 Correct 2 ms 512 KB Output is correct
20 Correct 2 ms 512 KB Output is correct
21 Correct 4 ms 572 KB Output is correct
22 Correct 5 ms 640 KB Output is correct
23 Correct 5 ms 640 KB Output is correct
24 Correct 4 ms 640 KB Output is correct
25 Correct 4 ms 640 KB Output is correct
26 Correct 4 ms 640 KB Output is correct
27 Correct 4 ms 640 KB Output is correct
28 Correct 5 ms 640 KB Output is correct
29 Correct 5 ms 640 KB Output is correct
30 Correct 4 ms 640 KB Output is correct
31 Correct 4 ms 640 KB Output is correct
32 Correct 4 ms 640 KB Output is correct
33 Correct 1224 ms 17232 KB Output is correct
34 Correct 1187 ms 17252 KB Output is correct
35 Correct 1161 ms 17260 KB Output is correct
36 Correct 1154 ms 17260 KB Output is correct
37 Correct 1182 ms 17380 KB Output is correct
38 Correct 1161 ms 17260 KB Output is correct
39 Correct 1181 ms 17132 KB Output is correct
40 Correct 1166 ms 17208 KB Output is correct
41 Correct 1172 ms 17132 KB Output is correct
42 Correct 1156 ms 17132 KB Output is correct
43 Correct 1187 ms 17252 KB Output is correct
44 Correct 1165 ms 17260 KB Output is correct
45 Correct 1178 ms 17260 KB Output is correct
46 Correct 1315 ms 17124 KB Output is correct
47 Correct 1150 ms 17132 KB Output is correct
48 Correct 1181 ms 17260 KB Output is correct
49 Correct 1166 ms 17260 KB Output is correct
50 Correct 1187 ms 17260 KB Output is correct
51 Correct 1203 ms 17260 KB Output is correct
52 Correct 1235 ms 17240 KB Output is correct
53 Correct 1187 ms 17132 KB Output is correct
54 Correct 1145 ms 17248 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 640 KB Output is correct
2 Correct 4 ms 640 KB Output is correct
3 Correct 5 ms 640 KB Output is correct
4 Correct 4 ms 640 KB Output is correct
5 Correct 4 ms 640 KB Output is correct
6 Correct 4 ms 640 KB Output is correct
7 Correct 4 ms 640 KB Output is correct
8 Correct 4 ms 640 KB Output is correct
9 Correct 4 ms 640 KB Output is correct
10 Correct 4 ms 640 KB Output is correct
11 Correct 2 ms 512 KB Output is correct
12 Correct 2 ms 512 KB Output is correct
13 Correct 3 ms 512 KB Output is correct
14 Correct 2 ms 512 KB Output is correct
15 Correct 2 ms 512 KB Output is correct
16 Correct 3 ms 512 KB Output is correct
17 Correct 2 ms 512 KB Output is correct
18 Correct 3 ms 512 KB Output is correct
19 Correct 2 ms 512 KB Output is correct
20 Correct 2 ms 512 KB Output is correct
21 Correct 4 ms 572 KB Output is correct
22 Correct 5 ms 640 KB Output is correct
23 Correct 5 ms 640 KB Output is correct
24 Correct 4 ms 640 KB Output is correct
25 Correct 4 ms 640 KB Output is correct
26 Correct 4 ms 640 KB Output is correct
27 Correct 4 ms 640 KB Output is correct
28 Correct 5 ms 640 KB Output is correct
29 Correct 5 ms 640 KB Output is correct
30 Correct 4 ms 640 KB Output is correct
31 Correct 4 ms 640 KB Output is correct
32 Correct 4 ms 640 KB Output is correct
33 Correct 1224 ms 17232 KB Output is correct
34 Correct 1187 ms 17252 KB Output is correct
35 Correct 1161 ms 17260 KB Output is correct
36 Correct 1154 ms 17260 KB Output is correct
37 Correct 1182 ms 17380 KB Output is correct
38 Correct 1161 ms 17260 KB Output is correct
39 Correct 1181 ms 17132 KB Output is correct
40 Correct 1166 ms 17208 KB Output is correct
41 Correct 1172 ms 17132 KB Output is correct
42 Correct 1156 ms 17132 KB Output is correct
43 Correct 1187 ms 17252 KB Output is correct
44 Correct 1165 ms 17260 KB Output is correct
45 Correct 1178 ms 17260 KB Output is correct
46 Correct 1315 ms 17124 KB Output is correct
47 Correct 1150 ms 17132 KB Output is correct
48 Correct 1181 ms 17260 KB Output is correct
49 Correct 1166 ms 17260 KB Output is correct
50 Correct 1187 ms 17260 KB Output is correct
51 Correct 1203 ms 17260 KB Output is correct
52 Correct 1235 ms 17240 KB Output is correct
53 Correct 1187 ms 17132 KB Output is correct
54 Correct 1145 ms 17248 KB Output is correct
55 Correct 1205 ms 17260 KB Output is correct
56 Correct 1208 ms 17260 KB Output is correct
57 Correct 1220 ms 17124 KB Output is correct
58 Correct 1214 ms 17132 KB Output is correct
59 Correct 1203 ms 17252 KB Output is correct
60 Correct 1199 ms 17260 KB Output is correct
61 Correct 1189 ms 17132 KB Output is correct
62 Correct 1254 ms 17124 KB Output is correct
63 Correct 1204 ms 17124 KB Output is correct
64 Correct 1210 ms 17132 KB Output is correct
65 Incorrect 1495 ms 17132 KB Output isn't correct
66 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2035 ms 640 KB Time limit exceeded
2 Halted 0 ms 0 KB -