# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1167175 | spycoderyt | Harbingers (CEOI09_harbingers) | C++20 | 88 ms | 24644 KiB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 3e5+5;
struct Line{
int a,b;
int operator()(int x) {return a * x + b;};
}lines[N];
vector<pair<int,int> > A[N];
int dis[N],prep[N],v[N],dp[N];
int sz=1;
int inter(Line x,Line y) {
return (x.b - y.b) / (y.a - x.a);
}
stack<tuple<int,int,Line> > his;
void add(Line nw) {
int pos = sz, l = 1, r = sz-1;
while(l<=r){
int mid = (l+r)/2;
if(inter(lines[mid-1],nw) >= inter(lines[mid],nw)){
pos=mid;
r=mid-1;
}else l=mid+1;
}
his.emplace(sz,pos,lines[pos]);
lines[pos]=nw;
sz=pos+1;
}
int query(int x) {
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |