# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
287961 | PeppaPig | Discharging (NOI20_discharging) | C++14 | 183 ms | 22496 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define long long long
using namespace std;
const int N = 1e6 + 5;
struct CHT {
struct line {
long m, c;
line(long m, long c) : m(m), c(c) {}
long f(long x) { return m * x + c; }
};
int ptr = 0;
vector<line> vec;
bool bad(line a, line b, line c) {
return 1.0 * (c.c - a.c) / (a.m - c.m) <= 1.0 * (b.c - a.c) / (a.m - b.m);
}
void add(long m, long c) {
line l(m, c);
while(vec.size() > 1 && bad(vec[(int)vec.size() - 2], vec.back(), l))
vec.pop_back();
vec.emplace_back(l);
}
long get_ans(long x) {
if(ptr >= (int)vec.size()) ptr = (int)vec.size() - 1;
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |