CSES - Increasing Array II

Author: Dong Liu


Time Complexity: O(NlogN)\mathcal O(N\log N)

This problem is similar to CF 713C except that we're supposed to create a non-decreasing array.

Here is zscoder's tutorial.

C++

#include <queue>
#include <stdio.h>
using namespace std;
int n, t;
long long ans = 0;
priority_queue<int> Q;
int main() {
scanf("%d", &n);

Join the USACO Forum!

Stuck on a problem, or don't understand a module? Join the USACO Forum and get help from other competitive programmers!