Tag Archives: sorting
Educational Codeforces Round 129 – Problem C
You are given two arrays a and b, both consisting of n integers. In one move, you can choose two indices i and j (1≤i,j≤n; i≠j) and swap ai with aj and bi with bj. You have to perform the swap in both arrays. You are allowed to perform at most 104 moves (possibly, zero)….
Educational Codeforces Round 129 – Problem A
Alice and Bob play a game. Alice has n cards, the i-th of them has the integer ai written on it. Bob has m cards, the j-th of them has the integer bj written on it. On the first turn of the game, the first player chooses one of his/her cards and puts it on…
Codeforces Round #793 – Problem B
B. AND Sorting time limit per test: 1 second memory limit per test: 256 megabytes input: standard input output: standard output You are given a permutation p of integers from 0 to n−1 (each of them occurs exactly once). Initially, the permutation is not sorted (that is, pi>pi+1 for at least one 1≤i≤n−1). The permutation…
Google CodeJam 2022 – Qualification – 3. d1000000
Problem While the most typical type of dice have 6 sides, each of which shows a different integer 1 through 6, there are many games that use other types. In particular, a dk is a die with k sides, each of which shows a different integer 1 through k. A d6 is a typical die, a d4 has four sides, and a d1000000 has one million sides. In this problem, we start with…
Codeforces Round #778 – Problem A
A. Maximum Cake Tastiness time limit per test: 2 seconds memory limit per test: 256 megabytes input: standard input output: standard output There are n pieces of cake on a line. The i-th piece of cake has weight ai (1≤i≤n). The tastiness of the cake is the maximum total weight of two adjacent pieces of cake (i. e., max(a1+a2,a2+a3,…,an−1+an)). You want to…