# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
96106 | gs14004 | Split the sequence (APIO14_sequence) | C++17 | 150 ms | 6348 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 lint;
typedef long double llf;
typedef pair<lint, int> pi;
const int MAXN = 100005;
struct line{ lint x, y; int cnt, idx; };
struct cht{
vector<line> v;
int p = 0;
void clear(){ v.clear(); p = 0; }
bool bad(line x, line y, line z){
return (llf)(x.y - y.y) / (y.x - x.x) >= (llf)(z.y - y.y) / (y.x - z.x);
}
void add(line l){
if(v.size() > p && v.back().x == l.x){
if(l.y < v.back().y) l = v.back();
v.pop_back();
}
while(v.size() >= p + 2 && bad(v[v.size()-2], v.back(), l)){
v.pop_back();
}
v.push_back(l);
}
tuple<lint, int, int> query(lint x){
while(p + 1 < v.size() && v[p].x * x + v[p].y <= v[p+1].x * x + v[p+1].y) p++;
return make_tuple(v[p].x * x + v[p].y, v[p].cnt, v[p].idx);
}
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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |