Solutions are presented as using the least memory and the fastest execution time. It also takes the top 10 most recent solutions from each language. If you want to limit to a specific index, click the "Solved" button and go to that problem.
ContestId |
Name |
Phase |
Frozen |
Duration (Seconds) |
Relative Time |
Start Time |
|---|---|---|---|---|---|---|
| 2087 | Kotlin Heroes: Episode 12 | FINISHED | False | 9000 | 32369123 | April 7, 2025, 2:35 p.m. |
Solved |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
|---|---|---|---|---|---|---|
| ( 488 ) | C | Coin Game | PROGRAMMING | *special greedy |
There are some coins arranged in a line, numbered from (1) from left to right. There are three types of coins: gold, silver, and bronze. Two players play a game; players take turns, and the first player makes the first turn. In one turn, the player chooses one of the three types of coins, and then collects all coins of that type which are still not taken by the other player. The game continues until all the coins are collected. Both players play optimally, and each player wants to maximize the number of coins he/she gets. Your task is to answer (q) independent queries of the following form: how many coins can the first player collect if the game is played using only coins with indices from (l) to (r) inclusive. The first line contains a string (s) ((1 \le |s| \le 10^5)), consisting of the characters G , S , and/or B . G means that the coin is gold. S means that the coin is silver. B means that the coin is bronze. The second line contains a single integer (q) ((1 \le q \le 10^5)) — the number of queries. Then (q) lines follow; each of them contains two integers (l) and (r) ((1 \le l \le r \le |s|)). For each query, print a single integer — the number of coins the first player can collect if the game is played using only coins with indices from (l) to (r) inclusive. Let's consider the queries from the example: In the first query, all coins are in the game. The optimal play can proceed as follows: the first player takes all the bronze coins, the second takes all the gold coins, and finally, the first player takes all the silver coins. Then the first player will collect (5) coins; In the second query, the coins from the (2)-nd to the (6)-th are in the game. The optimal play can proceed as follows: the first player takes all the silver coins, the second takes all the gold coins, and finally, the first player takes all the bronze coins. Then the first player will collect (3) coins; In the th |
| 141608 |
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 314380678 | kitsuna | C | April 7, 2025, 3 p.m. | OK | Kotlin 1.7 | TESTS | 4 | 468 | 52428800 | ||
| 314379305 | Storm29 | C | April 7, 2025, 2:53 p.m. | OK | Kotlin 1.7 | TESTS | 4 | 499 | 52633600 | ||
| 314395899 | diya0312 | C | April 7, 2025, 4:32 p.m. | OK | Kotlin 1.7 | TESTS | 4 | 499 | 54988800 | ||
| 314379881 | potatoo | C | April 7, 2025, 2:56 p.m. | OK | Kotlin 1.7 | TESTS | 4 | 515 | 22835200 | ||
| 314379853 | ThienNhan13 | C | April 7, 2025, 2:56 p.m. | OK | Kotlin 1.7 | TESTS | 4 | 515 | 56524800 | ||
| 314395796 | sai.code | C | April 7, 2025, 4:31 p.m. | OK | Kotlin 1.7 | TESTS | 4 | 530 | 52428800 | ||
| 314400603 | freetshirtpaglu | C | April 7, 2025, 5:03 p.m. | OK | Kotlin 1.7 | TESTS | 4 | 546 | 56627200 | ||
| 314392654 | abhiailen | C | April 7, 2025, 4:11 p.m. | OK | Kotlin 1.7 | TESTS | 4 | 577 | 43315200 | ||
| 314391864 | Rajdeep333 | C | April 7, 2025, 4:05 p.m. | OK | Kotlin 1.7 | TESTS | 4 | 577 | 49868800 | ||
| 314389635 | usrapheal06 | C | April 7, 2025, 3:51 p.m. | OK | Kotlin 1.7 | TESTS | 4 | 593 | 48537600 | ||
| 314397537 | hackstar | C | April 7, 2025, 4:43 p.m. | OK | Kotlin 1.9 | TESTS | 4 | 187 | 0 | ||
| 314388135 | salinecrop | C | April 7, 2025, 3:42 p.m. | OK | Kotlin 1.9 | TESTS | 4 | 187 | 0 | ||
| 314378658 | anle05 | C | April 7, 2025, 2:50 p.m. | OK | Kotlin 1.9 | TESTS | 4 | 187 | 0 | ||
| 314376572 | arvindf232 | C | April 7, 2025, 2:40 p.m. | OK | Kotlin 1.9 | TESTS | 4 | 187 | 1331200 | ||
| 314383062 | T_PAVAN_NAGARAJU | C | April 7, 2025, 3:12 p.m. | OK | Kotlin 1.9 | TESTS | 4 | 202 | 0 | ||
| 314379154 | Burnol_if_feels_jealous | C | April 7, 2025, 2:52 p.m. | OK | Kotlin 1.9 | TESTS | 4 | 202 | 204800 | ||
| 314378845 | __jk__ | C | April 7, 2025, 2:51 p.m. | OK | Kotlin 1.9 | TESTS | 4 | 202 | 512000 | ||
| 314386239 | lto5 | C | April 7, 2025, 3:31 p.m. | OK | Kotlin 1.9 | TESTS | 4 | 202 | 716800 | ||
| 314381064 | thenymphsofdelphi | C | April 7, 2025, 3:02 p.m. | OK | Kotlin 1.9 | TESTS | 4 | 203 | 0 | ||
| 314383489 | utkarshhui | C | April 7, 2025, 3:15 p.m. | OK | Kotlin 1.9 | TESTS | 4 | 218 | 0 |
Back to search problems