답안 #64258

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
64258 2018-08-03T18:32:22 Z reality Bulldozer (JOI17_bulldozer) C++17
5 / 100
3 ms 384 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-6;
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;
    srand(time(0));
    int ind = rand() % n;
    for (int i = 0;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));
    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 2 ms 256 KB Output is correct
2 Correct 3 ms 256 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 3 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 3 ms 256 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 2 ms 356 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 3 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Incorrect 2 ms 256 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Incorrect 2 ms 256 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Incorrect 2 ms 256 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 3 ms 256 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 3 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 3 ms 256 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 2 ms 356 KB Output is correct
14 Correct 2 ms 256 KB Output is correct
15 Correct 2 ms 256 KB Output is correct
16 Correct 3 ms 256 KB Output is correct
17 Correct 2 ms 256 KB Output is correct
18 Correct 3 ms 384 KB Output is correct
19 Correct 2 ms 256 KB Output is correct
20 Incorrect 2 ms 256 KB Output isn't correct
21 Halted 0 ms 0 KB -