My issue
Why not block solutions of others. This way we can increase more users ?
My code
#include <bits/stdc++.h>
using namespace std;
int main() {
// your code goes here
}
Problem Link: Make All Zero Practice Coding Problem - CodeChef
Why not block solutions of others. This way we can increase more users ?
#include <bits/stdc++.h>
using namespace std;
int main() {
// your code goes here
}
Problem Link: Make All Zero Practice Coding Problem - CodeChef
Use Python it’s easy.
This is what my dad wrote.
for _ in range(int(input())):
n = int(input())
arr = [int(w) for w in input().split()]
least = 10**10
ops = []
for a in arr:
if a <= least:
least = a
ops.append(a)
else:
ops.append(0)
kill = [1] * n
force = [0] * n
if ops[-1] == 0:
force[-1] = 1
for i in range(n-2, -1, -1):
kill[i] = kill[i+1]
force[i] = force[i+1]
if ops[i] != 0:
kill[i] += 1
if ops[i] == 0:
force[i] += 1
ans = n
for i in range(n):
if ops[i] > 0:
this = ops[i] + force[i] + i
ans = min(ans, this)
print(ans)