# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
44787 | choikiwon | Long Distance Coach (JOI17_coach) | C++17 | 258 ms | 171392 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>
using namespace std;
typedef long long ll;
typedef long double lf;
typedef pair<ll, ll> pll;
const int MN = 200010;
struct CHT {
vector<ll> M, B;
void init() {
M.clear();
B.clear();
}
bool bad(int l1, int l2, int l3) {
return (lf)(B[l3] - B[l1]) / (M[l1] - M[l3]) <= (lf)(B[l2] - B[l1]) / (M[l1] - M[l2]) + 1e-12;
}
void add(ll m, ll b) {
M.push_back(m);
B.push_back(b);
while(M.size() >= 3 && bad(M.size() - 3, M.size() - 2, M.size() - 1)) {
M.erase(M.end() - 2);
B.erase(B.end() - 2);
}
if(M.size() == 2 && M[0] == M[1]) {
M.erase(M.end() - 2);
B.erase(B.end() - 2);
}
}
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... |