Submission #229347

# Submission time Handle Problem Language Result Execution time Memory
229347 2020-05-04T09:42:59 Z fedoseevtimofey Bulldozer (JOI17_bulldozer) C++14
0 / 100
7 ms 512 KB
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <iomanip>
#include <functional>
#include <cassert>

using namespace std;

typedef long long ll;

struct point {
  int x, y;
  point(int x, int y) : x(x), y(y) {}
  point(int x) : x(x), y(x) {}
  point() : x(0), y(0) {}
  point operator -(const point &p) const {
    return point(x - p.x, y - p.y);
  }
  ll operator *(const point &p) const {
    return (ll)x * p.y - (ll)y * p.x;
  }
  int type() const {
    return y > 0 || (y == 0 && x > 0);
  }
  bool operator ==(const point &p) const {
    return x == p.x && y == p.y;
  }
  bool operator <(const point &b) const {
    const point &a = *this;
    if (a.type() != b.type()) {
      return a.type() < b.type();
    }
    return a * b > 0;
  }
};

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
#endif
  int n;
  cin >> n;
  vector <point> a(n); vector <int> w(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i].x >> a[i].y >> w[i];
  }
  vector <pair <point, pair <int, int>>> dir;
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      dir.emplace_back(a[i] - a[j], make_pair(i, j));
    }
  }
  sort(dir.begin(), dir.end());
  vector <int> p(n);
  iota(p.begin(), p.end(), 0);
  sort(p.begin(), p.end(), [&] (int i, int j) {
    if (a[i].y != a[j].y) return a[i].y < a[j].y;
    return a[i].x > a[j].x;
  });
  vector <int> pos(n);
  for (int i = 0; i < n; ++i) pos[p[i]] = i;
  ll ans = 0;
  for (auto d : dir) {
    ll cur = 0;
    for (int i : p) {
      cur += w[i];
      cur = max(cur, 0LL);
      ans = max(ans, cur);
    }
    swap(p[pos[d.second.first]], p[pos[d.second.second]]);
    swap(pos[d.second.first], pos[d.second.second]);
  }
  {
    ll cur = 0;
    for (int i : p) {
      cur += w[i];
      cur = max(cur, 0LL);
      ans = max(ans, cur);
    }
  }
  cout << ans << '\n';
}

# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 512 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 512 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 512 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 512 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 512 KB Output isn't correct
2 Halted 0 ms 0 KB -