# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
253215 | maximath_1 | Potatoes and fertilizers (LMIO19_bulves) | C++11 | 196 ms | 8584 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.
/*
* LMIO 2019 Ptatoes and Fertilizers
* a - b shows the number of fertilizers spared
* Take the prefix sum of a - b
* The problem becomes:
- An operation allows increment
or decrement an element by 1
- Special case on the leftmost element
> can't be decremented, must be non-negative
- Special case on the rightmost element
> can't be incremented
- We want to make the array non-decreasing
* This can be solved with slope trick
* A similar problem: https://codeforces.com/contest/713/problem/C
* More about slope trick: https://codeforces.com/blog/entry/77298
*/
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <iostream>
#include <iomanip>
#include <queue>
using namespace std;
#define ll long long
int n;
ll pref[500005], a, b;
int main(){
# | 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... |