IOM 2021, Блиц — Задача 42

The Blitz-contest of IOM-2021

Условие

What does the following code do?

C++ program listing: includes bits/stdc++.h, uses namespace std, declares a global map mp from int to int and global ints sum, res, m, x. In main it reads n and m, sets mp[0]=1, then for i from 0 to n − 1 reads x, adds x to sum, adds mp[sum - m] to res and increments mp[sum]; finally it prints res followed by endl and returns 0.
  • Count the number of distinct values in the list.
  • Count the number of subarrays having sum mm.
  • Count the number of subarrays that have at most mm distinct values.
  • Maximum sum of values in a contiguous subarray with length between mm and xx.

Отговори

Решение


Оригинал в Архива: iom-2021-blitz-tasks-eng.pdf · официални решения: iom-2021-blitz-answers-eng.pdf