Блог пользователя MS1908

Автор MS1908, история, 5 лет назад, По-английски

I'm currently trying to solve problem AKBAR from SPOJ. My idea is to do BFS from each soldier based on strength of that soldier, and then if there is a city that is protected by 2 soldiers, or if in the end, there is a city that is not protected then the answer is No, otherwise Yes. But for some reason, my code got WA verdict. Any help on why this happened will be really appreciated.

My code: https://ideone.com/7cGTFC

Полный текст и комментарии »

  • Проголосовать: нравится
  • -4
  • Проголосовать: не нравится

Автор MS1908, история, 5 лет назад, По-английски

I'm trying to solve the following problem from Hanoi Olympiad in Informatics.

Problem: Given arrays $$$A$$$ $$$a_1,a_2,\ldots, a_m$$$ and $$$B$$$ $$$b_1,b_2,\ldots, b_n$$$. From $$$A$$$ we take $$$a_j, a_k$$$ and from $$$B$$$ we take $$$b_i$$$ such that the tuple formed by these numbers satisfies $$$a_j < b_i < a_k$$$ or $$$a_k < b_i < a_j$$$. Such triple is called special. These numbers will be remove from the original arrays, and we repeat the process with the remaining numbers of the arrays. Find the maximum number of special triples.

Input: First line contains $$$m, n$$$ ($$$2\le m\le 10^5, 2\le n\le 10^5$$$). The second line contains $$$a_1,a_2,\ldots, a_m$$$ ($$$1\le a_i\le 10^9$$$) and the third line contains $$$b_1,b_2,\ldots, b_n$$$ ($$$1\le b_i\le 10^9$$$).

Output: Maximum number of special triples.

**Example: **

Input:

5 3

5 1 3 2 2

2 4 3

Output:

2

Explanation: We can choose $$$a_1=5$$$, $$$a_4=2$$$, $$$b_2=4$$$ and $$$a_2=1$$$, $$$a_3=3$$$, $$$b_1=2$$$.

Полный текст и комментарии »

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

Автор MS1908, история, 5 лет назад, По-английски

So I'm having the following problem, which appeared in my university programming contest.

Problem: Given positive integers $$$M$$$ and $$$N$$$ $$$(1\le M\le 500,\,1\le N\le 100)$$$ and a $$$N$$$-tuple of positive integers $$$(a_1,a_2,...,a_N)$$$ $$$(1\le a_i\le 10,\, 1\le i\le N)$$$. Find the number of positive integers $$$N$$$-tuple $$$(k_1,k_2,...,k_N)$$$ such that $$$a_1k_1+a_2k_2+\cdots+a_Nk_N=M$$$.

Input: First line will be $$$N$$$ and $$$M$$$ $$$(1\le M\le 500,\,1\le N\le 100)$$$. Second line will be the tuple $$$(a_1,a_2,...,a_N)$$$ $$$(1\le a_i\le 10,\, 1\le i\le N)$$$.

Output: The number of solutions of the equation.

Полный текст и комментарии »

  • Проголосовать: нравится
  • +13
  • Проголосовать: не нравится