# | 제출 시각UTC-0 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
253215 | maximath_1 | Potatoes and fertilizers (LMIO19_bulves) | C++11 | 196 ms | 8584 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/*
* 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... |