답안 #338624

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

#include <bits/stdc++.h>

#define Task            "tasks"
#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;
}

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:98:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   98 |         freopen(Task".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
bulldozer.cpp:99:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   99 |         freopen(Task".out","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 40 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 49 ms 364 KB Output is correct
2 Correct 51 ms 364 KB Output is correct
3 Correct 57 ms 364 KB Output is correct
4 Correct 48 ms 364 KB Output is correct
5 Correct 47 ms 364 KB Output is correct
6 Correct 47 ms 364 KB Output is correct
7 Correct 51 ms 364 KB Output is correct
8 Correct 47 ms 364 KB Output is correct
9 Correct 55 ms 492 KB Output is correct
10 Correct 58 ms 364 KB Output is correct
11 Correct 0 ms 364 KB Output is correct
12 Correct 0 ms 364 KB Output is correct
13 Correct 0 ms 364 KB Output is correct
14 Correct 0 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 0 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 46 ms 364 KB Output is correct
22 Correct 45 ms 364 KB Output is correct
23 Correct 46 ms 364 KB Output is correct
24 Correct 46 ms 364 KB Output is correct
25 Correct 47 ms 492 KB Output is correct
26 Correct 46 ms 364 KB Output is correct
27 Correct 49 ms 492 KB Output is correct
28 Correct 51 ms 364 KB Output is correct
29 Correct 55 ms 364 KB Output is correct
30 Correct 48 ms 364 KB Output is correct
31 Correct 46 ms 364 KB Output is correct
32 Correct 49 ms 492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 49 ms 364 KB Output is correct
2 Correct 51 ms 364 KB Output is correct
3 Correct 57 ms 364 KB Output is correct
4 Correct 48 ms 364 KB Output is correct
5 Correct 47 ms 364 KB Output is correct
6 Correct 47 ms 364 KB Output is correct
7 Correct 51 ms 364 KB Output is correct
8 Correct 47 ms 364 KB Output is correct
9 Correct 55 ms 492 KB Output is correct
10 Correct 58 ms 364 KB Output is correct
11 Correct 0 ms 364 KB Output is correct
12 Correct 0 ms 364 KB Output is correct
13 Correct 0 ms 364 KB Output is correct
14 Correct 0 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 0 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 46 ms 364 KB Output is correct
22 Correct 45 ms 364 KB Output is correct
23 Correct 46 ms 364 KB Output is correct
24 Correct 46 ms 364 KB Output is correct
25 Correct 47 ms 492 KB Output is correct
26 Correct 46 ms 364 KB Output is correct
27 Correct 49 ms 492 KB Output is correct
28 Correct 51 ms 364 KB Output is correct
29 Correct 55 ms 364 KB Output is correct
30 Correct 48 ms 364 KB Output is correct
31 Correct 46 ms 364 KB Output is correct
32 Correct 49 ms 492 KB Output is correct
33 Execution timed out 2056 ms 492 KB Time limit exceeded
34 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 49 ms 364 KB Output is correct
2 Correct 51 ms 364 KB Output is correct
3 Correct 57 ms 364 KB Output is correct
4 Correct 48 ms 364 KB Output is correct
5 Correct 47 ms 364 KB Output is correct
6 Correct 47 ms 364 KB Output is correct
7 Correct 51 ms 364 KB Output is correct
8 Correct 47 ms 364 KB Output is correct
9 Correct 55 ms 492 KB Output is correct
10 Correct 58 ms 364 KB Output is correct
11 Correct 0 ms 364 KB Output is correct
12 Correct 0 ms 364 KB Output is correct
13 Correct 0 ms 364 KB Output is correct
14 Correct 0 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 0 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 46 ms 364 KB Output is correct
22 Correct 45 ms 364 KB Output is correct
23 Correct 46 ms 364 KB Output is correct
24 Correct 46 ms 364 KB Output is correct
25 Correct 47 ms 492 KB Output is correct
26 Correct 46 ms 364 KB Output is correct
27 Correct 49 ms 492 KB Output is correct
28 Correct 51 ms 364 KB Output is correct
29 Correct 55 ms 364 KB Output is correct
30 Correct 48 ms 364 KB Output is correct
31 Correct 46 ms 364 KB Output is correct
32 Correct 49 ms 492 KB Output is correct
33 Execution timed out 2056 ms 492 KB Time limit exceeded
34 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 40 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -