# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
341594 |
2020-12-30T07:09:11 Z |
KoD |
Bulldozer (JOI17_bulldozer) |
C++17 |
|
296 ms |
508 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, N)) {
if (i == j) {
continue;
}
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::map<i64, i64> map;
for (auto k: range(0, N)) {
if (j != k) {
map[a * X[k] + b * Y[k]] += W[k];
}
}
Vec<std::pair<i64, i64>> vec;
for (const auto p: map) {
vec.emplace_back(p.first, p.second);
}
const usize idx = std::lower_bound(vec.begin(), vec.end(), std::make_pair(a * X[i] + b * Y[i], -inf64)) - vec.begin();
{
i64 sum = vec[idx].second;
ans = std::max(ans, sum);
for (auto x = idx; x --> 0;) {
sum += vec[x].second;
ans = std::max(ans, sum);
}
}
{
i64 sum = vec[idx].second;
ans = std::max(ans, sum);
for (auto x = idx; ++x < vec.size();) {
sum += vec[x].second;
ans = std::max(ans, sum);
}
}
}
}
}
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 |
256 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 |
0 ms |
364 KB |
Output is correct |
12 |
Correct |
0 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 |
0 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
274 ms |
384 KB |
Output is correct |
2 |
Correct |
259 ms |
364 KB |
Output is correct |
3 |
Correct |
264 ms |
380 KB |
Output is correct |
4 |
Correct |
272 ms |
364 KB |
Output is correct |
5 |
Correct |
264 ms |
492 KB |
Output is correct |
6 |
Correct |
263 ms |
492 KB |
Output is correct |
7 |
Correct |
296 ms |
380 KB |
Output is correct |
8 |
Correct |
263 ms |
364 KB |
Output is correct |
9 |
Correct |
257 ms |
492 KB |
Output is correct |
10 |
Correct |
262 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 |
0 ms |
364 KB |
Output is correct |
17 |
Correct |
1 ms |
364 KB |
Output is correct |
18 |
Correct |
1 ms |
384 KB |
Output is correct |
19 |
Correct |
1 ms |
384 KB |
Output is correct |
20 |
Correct |
1 ms |
364 KB |
Output is correct |
21 |
Correct |
236 ms |
492 KB |
Output is correct |
22 |
Correct |
239 ms |
492 KB |
Output is correct |
23 |
Correct |
238 ms |
492 KB |
Output is correct |
24 |
Correct |
243 ms |
492 KB |
Output is correct |
25 |
Correct |
237 ms |
492 KB |
Output is correct |
26 |
Correct |
250 ms |
508 KB |
Output is correct |
27 |
Correct |
239 ms |
364 KB |
Output is correct |
28 |
Correct |
233 ms |
364 KB |
Output is correct |
29 |
Correct |
240 ms |
492 KB |
Output is correct |
30 |
Correct |
237 ms |
364 KB |
Output is correct |
31 |
Correct |
248 ms |
364 KB |
Output is correct |
32 |
Correct |
237 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
274 ms |
384 KB |
Output is correct |
2 |
Correct |
259 ms |
364 KB |
Output is correct |
3 |
Correct |
264 ms |
380 KB |
Output is correct |
4 |
Correct |
272 ms |
364 KB |
Output is correct |
5 |
Correct |
264 ms |
492 KB |
Output is correct |
6 |
Correct |
263 ms |
492 KB |
Output is correct |
7 |
Correct |
296 ms |
380 KB |
Output is correct |
8 |
Correct |
263 ms |
364 KB |
Output is correct |
9 |
Correct |
257 ms |
492 KB |
Output is correct |
10 |
Correct |
262 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 |
0 ms |
364 KB |
Output is correct |
17 |
Correct |
1 ms |
364 KB |
Output is correct |
18 |
Correct |
1 ms |
384 KB |
Output is correct |
19 |
Correct |
1 ms |
384 KB |
Output is correct |
20 |
Correct |
1 ms |
364 KB |
Output is correct |
21 |
Correct |
236 ms |
492 KB |
Output is correct |
22 |
Correct |
239 ms |
492 KB |
Output is correct |
23 |
Correct |
238 ms |
492 KB |
Output is correct |
24 |
Correct |
243 ms |
492 KB |
Output is correct |
25 |
Correct |
237 ms |
492 KB |
Output is correct |
26 |
Correct |
250 ms |
508 KB |
Output is correct |
27 |
Correct |
239 ms |
364 KB |
Output is correct |
28 |
Correct |
233 ms |
364 KB |
Output is correct |
29 |
Correct |
240 ms |
492 KB |
Output is correct |
30 |
Correct |
237 ms |
364 KB |
Output is correct |
31 |
Correct |
248 ms |
364 KB |
Output is correct |
32 |
Correct |
237 ms |
364 KB |
Output is correct |
33 |
Runtime error |
1 ms |
492 KB |
Execution killed with signal 6 (could be triggered by violating memory limits) |
34 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
274 ms |
384 KB |
Output is correct |
2 |
Correct |
259 ms |
364 KB |
Output is correct |
3 |
Correct |
264 ms |
380 KB |
Output is correct |
4 |
Correct |
272 ms |
364 KB |
Output is correct |
5 |
Correct |
264 ms |
492 KB |
Output is correct |
6 |
Correct |
263 ms |
492 KB |
Output is correct |
7 |
Correct |
296 ms |
380 KB |
Output is correct |
8 |
Correct |
263 ms |
364 KB |
Output is correct |
9 |
Correct |
257 ms |
492 KB |
Output is correct |
10 |
Correct |
262 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 |
0 ms |
364 KB |
Output is correct |
17 |
Correct |
1 ms |
364 KB |
Output is correct |
18 |
Correct |
1 ms |
384 KB |
Output is correct |
19 |
Correct |
1 ms |
384 KB |
Output is correct |
20 |
Correct |
1 ms |
364 KB |
Output is correct |
21 |
Correct |
236 ms |
492 KB |
Output is correct |
22 |
Correct |
239 ms |
492 KB |
Output is correct |
23 |
Correct |
238 ms |
492 KB |
Output is correct |
24 |
Correct |
243 ms |
492 KB |
Output is correct |
25 |
Correct |
237 ms |
492 KB |
Output is correct |
26 |
Correct |
250 ms |
508 KB |
Output is correct |
27 |
Correct |
239 ms |
364 KB |
Output is correct |
28 |
Correct |
233 ms |
364 KB |
Output is correct |
29 |
Correct |
240 ms |
492 KB |
Output is correct |
30 |
Correct |
237 ms |
364 KB |
Output is correct |
31 |
Correct |
248 ms |
364 KB |
Output is correct |
32 |
Correct |
237 ms |
364 KB |
Output is correct |
33 |
Runtime error |
1 ms |
492 KB |
Execution killed with signal 6 (could be triggered by violating memory limits) |
34 |
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 |
256 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 |
0 ms |
364 KB |
Output is correct |
12 |
Correct |
0 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 |
0 ms |
364 KB |
Output is correct |
16 |
Correct |
274 ms |
384 KB |
Output is correct |
17 |
Correct |
259 ms |
364 KB |
Output is correct |
18 |
Correct |
264 ms |
380 KB |
Output is correct |
19 |
Correct |
272 ms |
364 KB |
Output is correct |
20 |
Correct |
264 ms |
492 KB |
Output is correct |
21 |
Correct |
263 ms |
492 KB |
Output is correct |
22 |
Correct |
296 ms |
380 KB |
Output is correct |
23 |
Correct |
263 ms |
364 KB |
Output is correct |
24 |
Correct |
257 ms |
492 KB |
Output is correct |
25 |
Correct |
262 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 |
0 ms |
364 KB |
Output is correct |
32 |
Correct |
1 ms |
364 KB |
Output is correct |
33 |
Correct |
1 ms |
384 KB |
Output is correct |
34 |
Correct |
1 ms |
384 KB |
Output is correct |
35 |
Correct |
1 ms |
364 KB |
Output is correct |
36 |
Correct |
236 ms |
492 KB |
Output is correct |
37 |
Correct |
239 ms |
492 KB |
Output is correct |
38 |
Correct |
238 ms |
492 KB |
Output is correct |
39 |
Correct |
243 ms |
492 KB |
Output is correct |
40 |
Correct |
237 ms |
492 KB |
Output is correct |
41 |
Correct |
250 ms |
508 KB |
Output is correct |
42 |
Correct |
239 ms |
364 KB |
Output is correct |
43 |
Correct |
233 ms |
364 KB |
Output is correct |
44 |
Correct |
240 ms |
492 KB |
Output is correct |
45 |
Correct |
237 ms |
364 KB |
Output is correct |
46 |
Correct |
248 ms |
364 KB |
Output is correct |
47 |
Correct |
237 ms |
364 KB |
Output is correct |
48 |
Runtime error |
1 ms |
492 KB |
Execution killed with signal 6 (could be triggered by violating memory limits) |
49 |
Halted |
0 ms |
0 KB |
- |