답안 #338523

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
338523 2020-12-23T10:17:45 Z KazamaHoang Bulldozer (JOI17_bulldozer) C++14
0 / 100
339 ms 492 KB
/* -> Written by <-
   -----------
  K_A_Z_A_M_A
  ___________
      _    |
  |   (^_^)   |
  |  /( | )\  |
  |____|_|____|
    H O A N G
*/

#include <bits/stdc++.h>

#define Task            ""
#define F               first
#define S               second
#define pb              push_back
#define bit(x, i)       ((x >> (i)) & 1)
#define inf             1e9 + 7
#define INF             1e18 + 7
#define ll              long long
#define pii             pair <int, int>
#define debug(x)        cerr << #x << " is " << x << "\n";

using namespace std;

const int MOD = 1e9 + 7;
const int maxn = 1e5 + 5;

int n;
pair <pii, int> a[maxn];

struct LINE{
    ll A, B, C;
};

pii Vt(pair<pii, int> p, pair<pii, int> q){
    return {q.F.F - p.F.F, q.F.S - p.F.S};
}

LINE Make_Line(pair<pii, int> p, pair<pii, int> q){
    pii u = Vt(p, q);
    LINE c;
    c.A = u.S;
    c.B = - u.F;
    c.C = 1ll * p.F.S * u.F - 1ll * p.F.F * u.S;
    return c;
}

ll DisToLine(pair<pii, int> p, LINE d){
    return abs(1ll * d.A * p.F.F + 1ll * d.B * p.F.S + d.C);
}

void Solve(){
    cin >> n;
    for (int i = 1; i <= n; ++ i){
        int x, y, w;
        cin >> x >> y >> w;
        a[i] = {{x, y}, w};
    }
    ll res = 0;
    for (int i = 1; i <= n; ++ i){
        res = max(res, (ll)a[i].S);
        for (int j = i + 1; j <= n; ++ j){
            LINE l = Make_Line(a[i], a[j]);
            for (int h = 1; h <= n; ++ h)
                if (h != i){
                    ll sdh = 1ll * l.A * a[h].F.F + 1ll * l.B * a[h].F.S + l.C;
                    ll c = DisToLine(a[h], l);
                    ll ans = 0;
                    for (int k = 1; k <= n; ++ k)
                        if (k != i && k != j && k != h){
                            ll sdk = 1ll * l.A * a[k].F.F + 1ll * l.B * a[k].F.S + l.C;
                            if (sdh > 0 && sdk < 0) continue;
                            if (sdh < 0 && sdk > 0) continue;
                            ll d = DisToLine(a[k], l);
                            if (c >= d) ans += a[k].S;
                        }
                    ll x = a[i].S + a[j].S + a[h].S;
                    if (h == j) x -= a[h].S;
                    res = max(res, ans + x);
                }
        }
    }
    cout << res;
}

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    if(fopen(Task".inp", "r")){
        freopen(Task".inp","r",stdin);
        freopen(Task".out","w",stdout);
    }
    int test_case = 1;
//     cin >> test_case;
    while (test_case --){
        Solve();
    }

    return 0;
}



Compilation message

bulldozer.cpp: In function 'int main()':
bulldozer.cpp:91:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   91 |         freopen(Task".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
bulldozer.cpp:92:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   92 |         freopen(Task".out","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 174 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 339 ms 492 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 339 ms 492 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 339 ms 492 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 174 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -