Submission #341569

# Submission time Handle Problem Language Result Execution time Memory
341569 2020-12-30T03:52:20 Z KoD Bulldozer (JOI17_bulldozer) C++17
5 / 100
62 ms 492 KB
#line 1 "main.cpp"

/**
 * @title Template
 */

#include <iostream>
#include <algorithm>
#include <utility>
#include <numeric>
#include <vector>
#include <array>
#include <cassert>
#include <map>

#line 2 "/Users/kodamankod/Desktop/cpp_programming/Library/other/range.cpp"

#line 4 "/Users/kodamankod/Desktop/cpp_programming/Library/other/range.cpp"

class range {
  struct iter {
    std::size_t itr;
    constexpr iter(std::size_t pos) noexcept: itr(pos) { }
    constexpr void operator ++ () noexcept { ++itr; }
    constexpr bool operator != (iter other) const noexcept { return itr != other.itr; }
    constexpr std::size_t operator * () const noexcept { return itr; }
  };

  struct reviter {
    std::size_t itr;
    constexpr reviter(std::size_t pos) noexcept: itr(pos) { }
    constexpr void operator ++ () noexcept { --itr; }
    constexpr bool operator != (reviter other) const noexcept { return itr != other.itr; }
    constexpr std::size_t operator * () const noexcept { return itr; }
  };

  const iter first, last;

public:
  constexpr range(std::size_t first, std::size_t last) noexcept: first(first), last(std::max(first, last)) { }
  constexpr iter begin() const noexcept { return first; }
  constexpr iter end() const noexcept { return last; }
  constexpr reviter rbegin() const noexcept { return reviter(*last - 1); } 
  constexpr reviter rend() const noexcept { return reviter(*first - 1); } 
};

/**
 * @title Range
 */
#line 16 "main.cpp"

using i32 = std::int32_t;
using i64 = std::int64_t;
using u32 = std::uint32_t;
using u64 = std::uint64_t;
using isize = std::ptrdiff_t;
using usize = std::size_t;

constexpr i32 inf32 = (u32) ~0 >> 2;
constexpr i64 inf64 = (u64) ~0 >> 2;

template <class T>
using Vec = std::vector<T>;

int main() {
  usize N;
  std::cin >> N;
  assert(N <= 100);
  Vec<i64> X(N), Y(N), W(N);
  for (auto i: range(0, N)) {
    std::cin >> X[i] >> Y[i] >> W[i];
  }
  if (std::count(Y.begin(), Y.end(), 0) == (isize) N) {
    std::map<i64, i64> map;
    for (auto i: range(0, N)) {
      map[X[i]] += W[i];
    }
    i64 ans = 0;
    i64 sum = 0;
    i64 min = 0;
    for (const auto [_, w]: map) {
      sum += w;
      min = std::min(min, sum);
      ans = std::max(ans, sum - min);
    }
    std::cout << ans << '\n';
    return 0;
  }
  i64 ans = 0;
  for (auto i: range(0, N)) {
    ans = std::max(ans, W[i]);
  }
  for (auto i: range(0, N)) {
    for (auto j: range(0, i)) {
      const auto a = (Y[i] - Y[j]);
      const auto b = (X[j] - X[i]);
      std::map<i64, i64> map;
      for (auto k: range(0, N)) {
        map[a * X[k] + b * Y[k]] += W[k];
      }
      i64 min = 0;
      i64 sum = 0;
      for (const auto [_, w]: map) {
        sum += w;
        min = std::min(min, sum);
        ans = std::max(ans, sum - min);
      }
    }
  }
  std::cout << ans << '\n';
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 58 ms 364 KB Output is correct
2 Correct 59 ms 364 KB Output is correct
3 Correct 58 ms 492 KB Output is correct
4 Correct 58 ms 364 KB Output is correct
5 Correct 60 ms 492 KB Output is correct
6 Correct 58 ms 364 KB Output is correct
7 Correct 58 ms 364 KB Output is correct
8 Correct 58 ms 492 KB Output is correct
9 Correct 62 ms 492 KB Output is correct
10 Correct 60 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 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 1 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 52 ms 364 KB Output is correct
22 Correct 55 ms 364 KB Output is correct
23 Correct 52 ms 364 KB Output is correct
24 Correct 54 ms 364 KB Output is correct
25 Incorrect 53 ms 364 KB Output isn't correct
26 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 58 ms 364 KB Output is correct
2 Correct 59 ms 364 KB Output is correct
3 Correct 58 ms 492 KB Output is correct
4 Correct 58 ms 364 KB Output is correct
5 Correct 60 ms 492 KB Output is correct
6 Correct 58 ms 364 KB Output is correct
7 Correct 58 ms 364 KB Output is correct
8 Correct 58 ms 492 KB Output is correct
9 Correct 62 ms 492 KB Output is correct
10 Correct 60 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 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 1 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 52 ms 364 KB Output is correct
22 Correct 55 ms 364 KB Output is correct
23 Correct 52 ms 364 KB Output is correct
24 Correct 54 ms 364 KB Output is correct
25 Incorrect 53 ms 364 KB Output isn't correct
26 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 58 ms 364 KB Output is correct
2 Correct 59 ms 364 KB Output is correct
3 Correct 58 ms 492 KB Output is correct
4 Correct 58 ms 364 KB Output is correct
5 Correct 60 ms 492 KB Output is correct
6 Correct 58 ms 364 KB Output is correct
7 Correct 58 ms 364 KB Output is correct
8 Correct 58 ms 492 KB Output is correct
9 Correct 62 ms 492 KB Output is correct
10 Correct 60 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 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 1 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 52 ms 364 KB Output is correct
22 Correct 55 ms 364 KB Output is correct
23 Correct 52 ms 364 KB Output is correct
24 Correct 54 ms 364 KB Output is correct
25 Incorrect 53 ms 364 KB Output isn't correct
26 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 58 ms 364 KB Output is correct
17 Correct 59 ms 364 KB Output is correct
18 Correct 58 ms 492 KB Output is correct
19 Correct 58 ms 364 KB Output is correct
20 Correct 60 ms 492 KB Output is correct
21 Correct 58 ms 364 KB Output is correct
22 Correct 58 ms 364 KB Output is correct
23 Correct 58 ms 492 KB Output is correct
24 Correct 62 ms 492 KB Output is correct
25 Correct 60 ms 364 KB Output is correct
26 Correct 1 ms 364 KB Output is correct
27 Correct 1 ms 364 KB Output is correct
28 Correct 1 ms 364 KB Output is correct
29 Correct 1 ms 364 KB Output is correct
30 Correct 1 ms 364 KB Output is correct
31 Correct 1 ms 364 KB Output is correct
32 Correct 1 ms 364 KB Output is correct
33 Correct 1 ms 364 KB Output is correct
34 Correct 1 ms 364 KB Output is correct
35 Correct 1 ms 364 KB Output is correct
36 Correct 52 ms 364 KB Output is correct
37 Correct 55 ms 364 KB Output is correct
38 Correct 52 ms 364 KB Output is correct
39 Correct 54 ms 364 KB Output is correct
40 Incorrect 53 ms 364 KB Output isn't correct
41 Halted 0 ms 0 KB -