# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1140845 | Luvidi | Discharging (NOI20_discharging) | C++17 | 84 ms | 15944 KiB |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll, ll>
#define pii pair<int, int>
#define fs first
#define sc second
#define pb push_back
double ins(pll p1,pll p2){
double x=p1.sc-p2.sc,y=p2.fs-p1.fs;
return x/y;
}
void solve() {
int n;
cin>>n;
ll a[n+1];
for(int i=1;i<=n;i++)cin>>a[i];
vector<pll> ch;
ll dp[n+1];
dp[0]=0;
int idx=0,lg=0;
for(int i=1;i<=n;i++){
if(!lg||a[i]>a[lg]){
for(int j=lg+1;j<=i;j++){
pll p={n-j+1,dp[j-1]};
while(ch.size()>1&&ins(ch[ch.size()-2],ch.back())>ins(ch.back(),p))ch.pop_back();
ch.push_back(p);
# | 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... |