이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/* -> Written by <-
   -----------
  K_A_Z_A_M_A
  ___________
      _    |
  |   (^_^)   |
  |  /( | )\  |
  |____|_|____|
    H O A N G
*/
#include <bits/stdc++.h>
#define Task            "bulldozer"
#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 dis(pair<pii, int> p, LINE c){
    return (c.A * p.F.F + c.B * p.F.S + c.C);
}
pair <ll, int> b[maxn], v[maxn];
ll Cal(pair<ll, int> t[], int cnt){
    sort(t + 1, t + 1 + cnt);
    ll s = 0;
    ll res = 0;
    for (int i = 1; i <= cnt; ++ i){
        s += a[t[i].S].S;
        res = max(res, s);
    }
    return res;
}
void Solve(){
    cin >> n;
    for (int i = 1; i <= n; ++ i){
        cin >> a[i].F.F >> a[i].F.S >> a[i].S;
    }
    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){
            int cnt = 0;
            LINE c = Make_Line(a[i], a[j]);
            for (int h = 1; h <= n; ++ h){
                b[++cnt] = {dis(a[h], c), a[h].S};
            }
            sort(b + 1, b + 1 + cnt);
            for (int h = 1; h <= n; ++ h){
                ll s = 0;
                for (int k = h; k <= n; ++ k){
                    s += b[k].S;
                    res = max(res, s);
                }
            }
        }
    }
    cout << res;
//    pair <pii, int> o = {{2, 3}, 1};
//    pair <pii, int> z = {{5, 2}, 1};
//    LINE c = Make_Line(o, z);
//    cout << c.A << " " << c.B << " " << c.C << " ";
}
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;
}
컴파일 시 표준 에러 (stderr) 메시지
bulldozer.cpp: In function 'int main()':
bulldozer.cpp:102:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
  102 |         freopen(Task".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
bulldozer.cpp:103:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
  103 |         freopen(Task".out","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |