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 |
|---|---|---|---|---|---|---|
| 1891 | Codeforces Round 907 (Div. 2) | FINISHED | False | 7200 | 77729123 | Oct. 30, 2023, 2:35 p.m. |
Solved |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
|---|---|---|---|---|---|---|
| ( 1079 ) | E | Brukhovich and Exams | PROGRAMMING | brute force greedy math sortings |
The boy Smilo is learning algorithms with a teacher named Brukhovich. Over the course of the year, Brukhovich will administer (n) exams. For each exam, its difficulty (a_i) is known, which is a non-negative integer. Smilo doesn't like when the greatest common divisor of the difficulties of two consecutive exams is equal to (1). Therefore, he considers the sadness of the academic year to be the number of such pairs of exams. More formally, the sadness is the number of indices (i) ((1 \leq i \leq n - 1)) such that (gcd(a_i, a_{i+1}) = 1), where (gcd(x, y)) is the greatest common divisor of integers (x) and (y). Brukhovich wants to minimize the sadness of the year of Smilo. To do this, he can set the difficulty of any exam to (0). However, Brukhovich doesn't want to make his students' lives too easy. Therefore, he will perform this action no more than (k) times. Help Smilo determine the minimum sadness that Brukhovich can achieve if he performs no more than (k) operations. As a reminder, the greatest common divisor (GCD) of two non-negative integers (x) and (y) is the maximum integer that is a divisor of both (x) and (y) and is denoted as (gcd(x, y)). In particular, (gcd(x, 0) = gcd(0, x) = x) for any non-negative integer (x). The first line contains a single integer (t) ((1 \leq t \leq 10^4)) — the number of test cases. The descriptions of the test cases follow. The first line of each test case contains two integers (n) and (k) ((1 \leq k \leq n \leq 10^5)) — the total number of exams and the maximum number of exams that can be simplified, respectively. The second line of each test case contains (n) integers (a_1, a_2, a_3, \ldots, a_n) — the elements of array (a), which are the difficulties of the exams ((0 \leq a_i \leq 10^9)). It is guaranteed that the sum of (n) across all test cases does not exceed (10^5). For each test case, output th |
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 230573475 | Tdyx | E | Oct. 30, 2023, 4:34 p.m. | OK | C# 10 | TESTS | 32 | 77 | 8601600 | ||
| 230581843 | Sparkle_Twilight | E | Oct. 30, 2023, 5:34 p.m. | OK | GNU C11 | TESTS | 32 | 62 | 819200 | ||
| 230576388 | szflc | E | Oct. 30, 2023, 5:08 p.m. | OK | GNU C++14 | TESTS | 32 | 46 | 1228800 | ||
| 230577974 | superguymj | E | Oct. 30, 2023, 5:13 p.m. | OK | GNU C++14 | TESTS | 32 | 61 | 4812800 | ||
| 230568747 | Kaitokid | E | Oct. 30, 2023, 4:24 p.m. | OK | GNU C++14 | TESTS | 32 | 62 | 512000 | ||
| 230613834 | woee | E | Oct. 31, 2023, 12:44 a.m. | OK | GNU C++14 | TESTS | 32 | 62 | 819200 | ||
| 230622900 | RemakerQwQ | E | Oct. 31, 2023, 3:24 a.m. | OK | GNU C++14 | TESTS | 32 | 62 | 819200 | ||
| 230570102 | KeroQ | E | Oct. 30, 2023, 4:27 p.m. | OK | GNU C++14 | TESTS | 32 | 62 | 921600 | ||
| 230565567 | sak_kn | E | Oct. 30, 2023, 4:16 p.m. | OK | GNU C++14 | TESTS | 32 | 109 | 6553600 | ||
| 230590244 | dthien2212 | E | Oct. 30, 2023, 6:33 p.m. | OK | GNU C++17 | TESTS | 32 | 46 | 512000 | ||
| 230613676 | archiver | E | Oct. 31, 2023, 12:41 a.m. | OK | GNU C++17 | TESTS | 32 | 46 | 512000 | ||
| 230567059 | ZzzzRKkkkkRrrrr | E | Oct. 30, 2023, 4:20 p.m. | OK | GNU C++17 | TESTS | 32 | 61 | 716800 | ||
| 230582684 | serotonin | E | Oct. 30, 2023, 5:39 p.m. | OK | GNU C++17 | TESTS | 32 | 61 | 2662400 | ||
| 230592554 | prvocislo | E | Oct. 30, 2023, 6:53 p.m. | OK | GNU C++17 | TESTS | 32 | 62 | 512000 | ||
| 230570241 | kimiyowaimo | E | Oct. 30, 2023, 4:27 p.m. | OK | GNU C++17 | TESTS | 32 | 62 | 819200 | ||
| 230604874 | EvenToWorldFinal | E | Oct. 30, 2023, 9:18 p.m. | OK | GNU C++17 | TESTS | 32 | 62 | 921600 | ||
| 230626881 | Shayan86 | E | Oct. 31, 2023, 5:46 a.m. | OK | GNU C++17 | TESTS | 32 | 62 | 1126400 | ||
| 230581893 | serotonin | E | Oct. 30, 2023, 5:34 p.m. | OK | GNU C++17 | TESTS | 32 | 62 | 2662400 | ||
| 230568327 | liympanda | E | Oct. 30, 2023, 4:23 p.m. | OK | GNU C++17 | TESTS | 32 | 77 | 614400 | ||
| 230620649 | enslaved | E | Oct. 31, 2023, 2:50 a.m. | OK | GNU C++17 (64) | TESTS | 32 | 31 | 819200 | ||
| 230623303 | prairie2022 | E | Oct. 31, 2023, 3:28 a.m. | OK | GNU C++17 (64) | TESTS | 32 | 46 | 102400 | ||
| 230623053 | prairie2022 | E | Oct. 31, 2023, 3:25 a.m. | OK | GNU C++17 (64) | TESTS | 32 | 46 | 102400 | ||
| 230566927 | Rubikun | E | Oct. 30, 2023, 4:20 p.m. | OK | GNU C++17 (64) | TESTS | 32 | 46 | 409600 | ||
| 230576616 | nicksms | E | Oct. 30, 2023, 5:08 p.m. | OK | GNU C++17 (64) | TESTS | 32 | 46 | 716800 | ||
| 230610641 | 21cs01033 | E | Oct. 30, 2023, 11:23 p.m. | OK | GNU C++17 (64) | TESTS | 32 | 46 | 921600 | ||
| 230568483 | hitonanode | E | Oct. 30, 2023, 4:23 p.m. | OK | GNU C++17 (64) | TESTS | 32 | 46 | 1126400 | ||
| 230611274 | Qg5 | E | Oct. 30, 2023, 11:42 p.m. | OK | GNU C++17 (64) | TESTS | 32 | 46 | 1228800 | ||
| 230576794 | real_Godot | E | Oct. 30, 2023, 5:08 p.m. | OK | GNU C++17 (64) | TESTS | 32 | 46 | 1536000 | ||
| 230569647 | MarcosK | E | Oct. 30, 2023, 4:26 p.m. | OK | GNU C++17 (64) | TESTS | 32 | 62 | 819200 | ||
| 230617964 | gxy001 | E | Oct. 31, 2023, 2:06 a.m. | OK | GNU C++20 (64) | TESTS | 32 | 31 | 409600 | ||
| 230584121 | ImNotCandyOreO3O | E | Oct. 30, 2023, 5:49 p.m. | OK | GNU C++20 (64) | TESTS | 32 | 31 | 409600 | ||
| 230620318 | riverwalk7 | E | Oct. 31, 2023, 2:44 a.m. | OK | GNU C++20 (64) | TESTS | 32 | 31 | 409600 | ||
| 230616394 | NatanVek | E | Oct. 31, 2023, 1:36 a.m. | OK | GNU C++20 (64) | TESTS | 32 | 31 | 512000 | ||
| 230576795 | joww | E | Oct. 30, 2023, 5:08 p.m. | OK | GNU C++20 (64) | TESTS | 32 | 31 | 819200 | ||
| 230566008 | MridulAhi | E | Oct. 30, 2023, 4:17 p.m. | OK | GNU C++20 (64) | TESTS | 32 | 31 | 921600 | ||
| 230615151 | catlover1 | E | Oct. 31, 2023, 1:11 a.m. | OK | GNU C++20 (64) | TESTS | 32 | 31 | 1024000 | ||
| 230618981 | Tobo | E | Oct. 31, 2023, 2:23 a.m. | OK | GNU C++20 (64) | TESTS | 32 | 31 | 1331200 | ||
| 230571123 | orz | E | Oct. 30, 2023, 4:29 p.m. | OK | GNU C++20 (64) | TESTS | 32 | 31 | 1638400 | ||
| 230611430 | gustavoleal | E | Oct. 30, 2023, 11:47 p.m. | OK | GNU C++20 (64) | TESTS | 32 | 31 | 1843200 | ||
| 230593230 | Dukkha | E | Oct. 30, 2023, 6:59 p.m. | OK | Java 17 | TESTS | 32 | 452 | 921600 | ||
| 230591490 | dusty.and.rusty | E | Oct. 30, 2023, 6:45 p.m. | OK | Java 17 | TESTS | 32 | 452 | 5529600 | ||
| 230570200 | vajaba | E | Oct. 30, 2023, 4:27 p.m. | OK | MS C++ 2017 | TESTS | 32 | 124 | 1024000 | ||
| 230617767 | RobinFromTheHood | E | Oct. 31, 2023, 2:02 a.m. | OK | PyPy 3-64 | TESTS | 32 | 233 | 19353600 | ||
| 230618194 | nandeeshwar2316 | E | Oct. 31, 2023, 2:10 a.m. | OK | PyPy 3-64 | TESTS | 32 | 249 | 13516800 | ||
| 230621581 | codicon | E | Oct. 31, 2023, 3:07 a.m. | OK | PyPy 3-64 | TESTS | 32 | 327 | 14540800 | ||
| 230586451 | lionel.m | E | Oct. 30, 2023, 6:05 p.m. | OK | PyPy 3-64 | TESTS | 32 | 514 | 13721600 | ||
| 230605752 | ruderumit | E | Oct. 30, 2023, 9:33 p.m. | OK | Python 3 | TESTS | 32 | 108 | 14950400 | ||
| 230572991 | byurak | E | Oct. 30, 2023, 4:33 p.m. | OK | Python 3 | TESTS | 32 | 108 | 14950400 |
Back to search problems