# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1158178 | nikolashami | Harbingers (CEOI09_harbingers) | C++20 | 123 ms | 32328 KiB |
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
#define int ll
const int N=1e5+4;
vector<array<int,2>>g[N];
int S[N],V[N],up[N][17],n;
ll F[N];
struct Line{
int k=0;ll nn=0;
ll f(int x){return(1ll*k*x)+nn;}
}C[N];
ld presek(Line x,Line y){
return(ld)(y.nn-x.nn)/(x.k-y.k);
}
ll get(int x,int u){
for(int i=16;i>=0;--i)
if(up[u][i]>1&&presek(C[up[u][i]],C[up[up[u][i]][0]])>=(ld)x)u=up[u][i];
return(min({0ll,C[u].f(x),C[up[u][0]].f(x),C[1].f(x)}));
}
void upd(int u,Line L){
int ou=u;u=up[u][0];
for(int i=16;i>=0;--i)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |