# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1169869 | MinhKien | Building Bridges (CEOI17_building) | C++20 | 51 ms | 65348 KiB |
#include <iostream>
using namespace std;
#define ll long long
const int N = 1e5 + 10;
const int M = 1e6 + 10;
const ll INF = 1e18;
int n;
ll h[N], w[N], dp[N];
struct lichao {
struct line {
ll a, b;
line() {a = b = INF;}
line(ll A, ll B) {a = A, b = B;}
ll calc(ll val) {return a == INF ? INF : a * val + b;}
ll slope() {return a;}
} st[M << 2];
void update(int l, int r, line f, int id) {
int m = (l + r) >> 1;
if (st[id].calc(m) > f.calc(m)) swap(st[id], f);
if (l == r) return;
if (f.slope() < st[id].slope()) update(m + 1, r, f, id << 1);
if (f.slope() > st[id].slope()) update(l, m, f, id << 1 | 1);
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |