답안 #341565

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
341565 2020-12-30T03:46:30 Z KoD Bulldozer (JOI17_bulldozer) C++17
0 / 100
64 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 (N == 1) {
    std::cout << std::max(W[0], (i64) 0) << '\n';
    return 0;
  }
  i64 ans = 0;
  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;
        ans = std::max(ans, sum - min);
        min = std::min(min, sum);
      }
    }
  }
  std::cout << ans << '\n';
  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 59 ms 364 KB Output is correct
2 Correct 64 ms 384 KB Output is correct
3 Correct 58 ms 492 KB Output is correct
4 Correct 58 ms 492 KB Output is correct
5 Correct 58 ms 364 KB Output is correct
6 Correct 57 ms 364 KB Output is correct
7 Correct 58 ms 364 KB Output is correct
8 Correct 58 ms 364 KB Output is correct
9 Correct 57 ms 364 KB Output is correct
10 Correct 58 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 0 ms 364 KB Output is correct
13 Incorrect 1 ms 384 KB Output isn't correct
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 59 ms 364 KB Output is correct
2 Correct 64 ms 384 KB Output is correct
3 Correct 58 ms 492 KB Output is correct
4 Correct 58 ms 492 KB Output is correct
5 Correct 58 ms 364 KB Output is correct
6 Correct 57 ms 364 KB Output is correct
7 Correct 58 ms 364 KB Output is correct
8 Correct 58 ms 364 KB Output is correct
9 Correct 57 ms 364 KB Output is correct
10 Correct 58 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 0 ms 364 KB Output is correct
13 Incorrect 1 ms 384 KB Output isn't correct
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 59 ms 364 KB Output is correct
2 Correct 64 ms 384 KB Output is correct
3 Correct 58 ms 492 KB Output is correct
4 Correct 58 ms 492 KB Output is correct
5 Correct 58 ms 364 KB Output is correct
6 Correct 57 ms 364 KB Output is correct
7 Correct 58 ms 364 KB Output is correct
8 Correct 58 ms 364 KB Output is correct
9 Correct 57 ms 364 KB Output is correct
10 Correct 58 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 0 ms 364 KB Output is correct
13 Incorrect 1 ms 384 KB Output isn't correct
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -