답안 #64261

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
64261 2018-08-03T18:50:02 Z reality Bulldozer (JOI17_bulldozer) C++17
5 / 100
38 ms 640 KB
#include "bits/stdc++.h"
using namespace std;
#define fi first
#define se second
#define ll long long
#define dbg(v) cerr<<#v<<" = "<<v<<'\n'
#define vi vector<int>
#define vl vector <ll>
#define pii pair<int,int>
#define mp make_pair
#define db long double
#define pb push_back
#define all(s) s.begin(),s.end()
template < class T > ostream& operator<<(ostream& stream, const vector<T> v){ stream << "[ "; for (int i=0; i<(int)v.size(); i++) stream << v[i] << " "; stream << "]"; return stream;}
template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;}
template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;}
const db eps = 1e-10;
int main(void) {
    map < int , ll > ox;
    int n;
    ll answer = 0;
    cin>>n;
    vector < pii > p(n);
    vi cost(n);
    int index = -1;
    for (auto & it : p) {
        ++index;
        cin>>it.fi>>it.se>>cost[index];
        ox[it.fi] += cost[index];
    }
    ll cnt = 0,sum = 0;
    for (auto it : ox) {
        sum += it.se;
        smax(answer,sum - cnt);
        smin(cnt,sum);
    }
    vector < db > M;
    for (int ind = 0;ind < n;++ind)
        for (int i = ind + 1;i < n;++i)
           if (p[i].fi != p[ind].fi)
                M.pb(1.0 * (p[i].se - p[ind].se) / (p[i].fi - p[ind].fi));
    random_shuffle(all(M));
    for (auto m : M) {
        vector < pair < db , int > > v;
        for (int i = 0;i < n;++i)
            v.pb(mp(p[i].se - m * p[i].fi,cost[i]));
        ll cnt = 0,sum = 0;
        sort(all(v));
        for (int i = 0,j = 0;i < n;i = j) {
            j = i;
            while (j < n && abs(v[i].fi - v[j].fi) < eps)
                sum += v[j].se,++j;
            smax(answer,sum - cnt);
            smin(cnt,sum);
        }
    }
    cout << answer << '\n';
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 512 KB Output is correct
2 Correct 26 ms 512 KB Output is correct
3 Correct 25 ms 512 KB Output is correct
4 Correct 25 ms 512 KB Output is correct
5 Correct 27 ms 512 KB Output is correct
6 Correct 25 ms 512 KB Output is correct
7 Correct 27 ms 512 KB Output is correct
8 Correct 26 ms 524 KB Output is correct
9 Correct 27 ms 512 KB Output is correct
10 Correct 26 ms 512 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 2 ms 256 KB Output is correct
14 Correct 2 ms 256 KB Output is correct
15 Correct 2 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 38 ms 512 KB Output is correct
2 Correct 37 ms 512 KB Output is correct
3 Correct 38 ms 512 KB Output is correct
4 Correct 38 ms 512 KB Output is correct
5 Correct 38 ms 512 KB Output is correct
6 Correct 37 ms 512 KB Output is correct
7 Correct 38 ms 512 KB Output is correct
8 Correct 37 ms 512 KB Output is correct
9 Correct 38 ms 512 KB Output is correct
10 Correct 38 ms 640 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Incorrect 2 ms 384 KB Output isn't correct
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 38 ms 512 KB Output is correct
2 Correct 37 ms 512 KB Output is correct
3 Correct 38 ms 512 KB Output is correct
4 Correct 38 ms 512 KB Output is correct
5 Correct 38 ms 512 KB Output is correct
6 Correct 37 ms 512 KB Output is correct
7 Correct 38 ms 512 KB Output is correct
8 Correct 37 ms 512 KB Output is correct
9 Correct 38 ms 512 KB Output is correct
10 Correct 38 ms 640 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Incorrect 2 ms 384 KB Output isn't correct
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 38 ms 512 KB Output is correct
2 Correct 37 ms 512 KB Output is correct
3 Correct 38 ms 512 KB Output is correct
4 Correct 38 ms 512 KB Output is correct
5 Correct 38 ms 512 KB Output is correct
6 Correct 37 ms 512 KB Output is correct
7 Correct 38 ms 512 KB Output is correct
8 Correct 37 ms 512 KB Output is correct
9 Correct 38 ms 512 KB Output is correct
10 Correct 38 ms 640 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Incorrect 2 ms 384 KB Output isn't correct
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 512 KB Output is correct
2 Correct 26 ms 512 KB Output is correct
3 Correct 25 ms 512 KB Output is correct
4 Correct 25 ms 512 KB Output is correct
5 Correct 27 ms 512 KB Output is correct
6 Correct 25 ms 512 KB Output is correct
7 Correct 27 ms 512 KB Output is correct
8 Correct 26 ms 524 KB Output is correct
9 Correct 27 ms 512 KB Output is correct
10 Correct 26 ms 512 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 2 ms 256 KB Output is correct
14 Correct 2 ms 256 KB Output is correct
15 Correct 2 ms 256 KB Output is correct
16 Correct 38 ms 512 KB Output is correct
17 Correct 37 ms 512 KB Output is correct
18 Correct 38 ms 512 KB Output is correct
19 Correct 38 ms 512 KB Output is correct
20 Correct 38 ms 512 KB Output is correct
21 Correct 37 ms 512 KB Output is correct
22 Correct 38 ms 512 KB Output is correct
23 Correct 37 ms 512 KB Output is correct
24 Correct 38 ms 512 KB Output is correct
25 Correct 38 ms 640 KB Output is correct
26 Correct 2 ms 384 KB Output is correct
27 Correct 2 ms 256 KB Output is correct
28 Incorrect 2 ms 384 KB Output isn't correct
29 Halted 0 ms 0 KB -