# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
964790 | Chmayank2009 | Building Bridges (CEOI17_building) | C++17 | 82 ms | 67288 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 <iostream>
#include <bits/stdc++.h>
using namespace std;
const long long inf=1e18;
const long long N=1e6+1;
struct Line{
long long m=0,c=inf;
};
vector<Line>seg(4*1e6+1);
long long calc(Line Li,long long x){
return Li.m*x+Li.c;
}
void insert(Line Li,long long i=1,long long l=0,long long r=N){
long long m=l+(r-l)/2;
long long mid=calc(Li,m)<calc(seg[i],m);
long long left=calc(Li,l)<calc(seg[i],l);
if(mid){
swap(seg[i],Li);
}
if(r-l==1) return;
if(left!=mid){
insert(Li,2*i,l,m);
}
else{
insert(Li,2*i+1,m,r);
}
}
long long get(long long x,long long i=1,long long l=0,long long r=N){
long long m=l+(r-l)/2;
long long curr=calc(seg[i],x);
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |