# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
261330 | Nightlight | Discharging (NOI20_discharging) | C++14 | 248 ms | 30052 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>
#define pii pair<long long, long long>
#define inter second
#define slope first
using namespace std;
int N;
long long A[1000005], ans = LLONG_MAX;
long long T[1000005];
long long pos[1000005];
long long dp[1000005];
pii CHT[100005];
int sz, pointer;
int p;
inline double isect(pii a, pii b) {return (a.inter - b.inter) / (b.slope - a.slope);}
inline bool bad(pii a, pii b, pii c) {return isect(c, a) < isect(a, b);}
inline long long val(long long X, int id) {return CHT[id].slope * X + CHT[id].inter;}
void insert(long long m, long long b) {
pii L = {m, b};
while(sz > 1 && bad(CHT[sz - 1], CHT[sz], L)) sz--;
CHT[++sz] = L;
}
long long query(long long X) {
long long res = LLONG_MAX;
// cout << X << "\n";
for(int i = 1; i <= sz; i++) {
res = min(res, val(X, i));
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... |