
Subarray Cuts
You are given an array of length n and a number k. Let’s pick k non-overlapping non-empty subarrays of the initial array. Let s i be the sum of the i-th subarray in order […]
You are given an array of length n and a number k. Let’s pick k non-overlapping non-empty subarrays of the initial array. Let s i be the sum of the i-th subarray in order […]
Cthulhu decided to catch Scaygerboss. Scaygerboss found it out and is trying to hide in a pack of his scaygers. Each scayger except Scaygerboss is […]
You are given a permutation of n numbers p 1, p 2, …, p n. We perform k operations of the following type: choose uniformly at random two indices l and r ( l ≤ r) and reverse the order of the elements p l, p l + 1, …, p r. […]
One day n friends met at a party, they hadn’t seen each other for a long time and so they decided to make a group photo together. […]
Polycarp is flying in the airplane. Finally, it is his favorite time — the lunchtime. The BerAvia company stewardess is giving food consecutively to all the […]
You are given sequence a 1, a 2, …, a n and m queries l j, r j (1 ≤ l j ≤ r j ≤ n). For each query you need to print the minimum distance between such pair of elements a x and a y ( x ≠ y), that: both indexes of the elements […]
ATMs of a well-known bank of a small country are arranged so that they can not give any amount of money requested by the user. […]
Polycarpus has a chessboard of size n × m, where k rooks are placed. Polycarpus hasn’t yet invented the rules of the game he will play. However, he has already […]
Polycarpus got an internship in one well-known social network. His test task is to count the number of unique users who have visited a social […]
Polycarpus has a finite sequence of opening and closing brackets. In order not to fall asleep in a lecture, Polycarpus is having fun with his […]
In this problem you will meet the simplified model of game King of Thieves. In a new ZeptoLab game called “King of Thieves” your aim […]
Om Nom is the main character of a game “Cut the Rope”. He is a bright little monster who likes visiting friends living at the […]
A sweet little monster Om Nom loves candies very much. One day he found himself in a rather tricky situation that required him to think […]
One day Om Nom found a thread with n beads of different colors. He decided to cut the first several beads from this thread to make a […]
Optimizing the amount of data transmitted via a network is an important and interesting part of developing any network application. In one secret game developed […]
Analyzing the mistakes people make while typing search queries is a complex and an interesting work. As there is no guaranteed way to determine what […]
One Big Software Company has n employees numbered from 1 to n. The director is assigned number 1. Every employee of the company except the director has exactly one immediate superior. […]
Polycarp and Vasiliy love simple logical games. Today they play a game with infinite chessboard and one pawn for each player. Polycarp and Vasiliy move […]