Submission #338621

# Submission time Handle Problem Language Result Execution time Memory
338621 2020-12-23T14:02:11 Z KazamaHoang Bulldozer (JOI17_bulldozer) C++14
0 / 100
56 ms 492 KB
/* -> 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;
}

Compilation message

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
1 Incorrect 39 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 52 ms 364 KB Output is correct
2 Correct 48 ms 364 KB Output is correct
3 Correct 47 ms 364 KB Output is correct
4 Correct 49 ms 364 KB Output is correct
5 Correct 48 ms 364 KB Output is correct
6 Correct 56 ms 364 KB Output is correct
7 Correct 47 ms 364 KB Output is correct
8 Correct 47 ms 364 KB Output is correct
9 Correct 47 ms 492 KB Output is correct
10 Correct 47 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Incorrect 0 ms 364 KB Output isn't correct
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 52 ms 364 KB Output is correct
2 Correct 48 ms 364 KB Output is correct
3 Correct 47 ms 364 KB Output is correct
4 Correct 49 ms 364 KB Output is correct
5 Correct 48 ms 364 KB Output is correct
6 Correct 56 ms 364 KB Output is correct
7 Correct 47 ms 364 KB Output is correct
8 Correct 47 ms 364 KB Output is correct
9 Correct 47 ms 492 KB Output is correct
10 Correct 47 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Incorrect 0 ms 364 KB Output isn't correct
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 52 ms 364 KB Output is correct
2 Correct 48 ms 364 KB Output is correct
3 Correct 47 ms 364 KB Output is correct
4 Correct 49 ms 364 KB Output is correct
5 Correct 48 ms 364 KB Output is correct
6 Correct 56 ms 364 KB Output is correct
7 Correct 47 ms 364 KB Output is correct
8 Correct 47 ms 364 KB Output is correct
9 Correct 47 ms 492 KB Output is correct
10 Correct 47 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Incorrect 0 ms 364 KB Output isn't correct
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 39 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -