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 |
---|---|---|---|---|---|---|
1973 | Codeforces Round 945 (Div. 2) | FINISHED | False | 7200 | 21223463 | May 17, 2024, 2:35 p.m. |
Solved$ |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
---|---|---|---|---|---|---|
( 245 ) | F | Maximum GCD Sum Queries | PROGRAMMING | bitmasks brute force dp implementation number theory | 3100 |
B'For k positive integers x_1, x_2, ldots, x_k , the value gcd(x_1, x_2, ldots, x_k) is the greatest common divisor of the integers x_1, x_2, ldots, x_k -- the largest integer z such that all the integers x_1, x_2, ldots, x_k are divisible by z . You are given three arrays a_1, a_2, ldots, a_n , b_1, b_2, ldots, b_n and c_1, c_2, ldots, c_n of length n , containing positive integers. You also have a machine that allows you to swap a_i and b_i for any i ( 1 <= i <= n ). Each swap costs you c_i coins. Find the maximum possible value of gcd(a_1, a_2, ldots, a_n) + gcd(b_1, b_2, ldots, b_n) that you can get by paying in total at most d coins for swapping some elements. The amount of coins you have changes a lot, so find the answer to this question for each of the q possible values d_1, d_2, ldots, d_q . There are two integers on the first line -- the numbers n and q ( 1 <= q n <= q 5 cdot 10^5 , 1 <= q q <= q 5 cdot 10^5 ). On the second line, there are n integers -- the numbers a_1, a_2, ldots, a_n ( 1 <= q a_i <= q 10^8 ). On the third line, there are n integers -- the numbers b_1, b_2, ldots, b_n ( 1 <= q b_i <= q 10^8 ). On the fourth line, there are n integers -- the numbers c_1, c_2, ldots, c_n ( 1 <= q c_i <= q 10^9 ). On the fifth line, there are q integers -- the numbers d_1, d_2, ldots, d_q ( 0 <= q d_i <= q 10^{15} ). Print q integers -- the maximum value you can get for each of the q possible values d . In the first query of the first example, we are not allowed to do any swaps at all, so the answer is gcd(1, 2, 3) + gcd(4, 5, 6) = 2 . In the second query, one of the ways to achieve the optimal value is to swap a_2 and b_2 , then the answer is gcd(1, 5, 3) + gcd(4, 2, 6) = 3$'... |
Editorial for Codeforces Round #945 (Div. 2) |
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
---|---|---|---|---|---|---|---|---|---|---|---|
261974407 | leelarishika | F | May 21, 2024, 7:14 a.m. | OK | C++14 (GCC 6-32) | TESTS | 39 | 1483 | 68915200 | 3100 | |
262207595 | liuhengxi | F | May 23, 2024, 2:02 a.m. | OK | C++14 (GCC 6-32) | TESTS | 39 | 1718 | 42496000 | 3100 | |
262456557 | Southern_Dynasty | F | May 25, 2024, 4:23 a.m. | OK | C++14 (GCC 6-32) | TESTS | 39 | 1796 | 87244800 | 3100 | |
262456931 | Southern_Dynasty | F | May 25, 2024, 4:28 a.m. | OK | C++14 (GCC 6-32) | TESTS | 39 | 1984 | 87244800 | 3100 | |
262991161 | ciuim | F | May 28, 2024, 9:53 a.m. | OK | C++14 (GCC 6-32) | TESTS | 39 | 3296 | 69324800 | 3100 | |
262411127 | mamun314 | F | May 24, 2024, 4:07 p.m. | OK | C++17 (GCC 7-32) | TESTS | 39 | 1202 | 63283200 | 3100 | |
261765809 | MOHAMEDNEMO | F | May 20, 2024, 10:50 a.m. | OK | C++17 (GCC 7-32) | TESTS | 39 | 1233 | 63283200 | 3100 | |
262161118 | v20481A5432 | F | May 22, 2024, 3:14 p.m. | OK | C++17 (GCC 7-32) | TESTS | 39 | 1264 | 63283200 | 3100 | |
263250090 | phirtheta | F | May 30, 2024, 12:47 p.m. | OK | C++17 (GCC 7-32) | TESTS | 39 | 1358 | 60723200 | 3100 | |
262696540 | dushenkov | F | May 26, 2024, 11:31 a.m. | OK | C++17 (GCC 7-32) | TESTS | 39 | 1421 | 473190400 | 3100 | |
261930756 | Kilani | F | May 20, 2024, 7:41 p.m. | OK | C++17 (GCC 7-32) | TESTS | 39 | 1452 | 51097600 | 3100 | |
262110406 | SoiMae | F | May 22, 2024, 8:04 a.m. | OK | C++17 (GCC 7-32) | TESTS | 39 | 1562 | 134348800 | 3100 | |
261699156 | ywjylx | F | May 19, 2024, 8:05 p.m. | OK | C++17 (GCC 7-32) | TESTS | 39 | 1718 | 56115200 | 3100 | |
262170245 | Dimitrovsd | F | May 22, 2024, 4:34 p.m. | OK | C++17 (GCC 7-32) | TESTS | 39 | 1812 | 83046400 | 3100 | |
261724562 | ywjylx | F | May 20, 2024, 5:21 a.m. | OK | C++17 (GCC 7-32) | TESTS | 39 | 1843 | 56217600 | 3100 | |
262635584 | neal | F | May 26, 2024, 1:41 a.m. | OK | C++20 (GCC 13-64) | TESTS | 39 | 358 | 75776000 | 3100 | |
262212034 | neal | F | May 23, 2024, 3:19 a.m. | OK | C++20 (GCC 13-64) | TESTS | 39 | 374 | 75776000 | 3100 | |
261949112 | Engineer | F | May 21, 2024, 1:44 a.m. | OK | C++20 (GCC 13-64) | TESTS | 39 | 515 | 63897600 | 3100 | |
262211157 | neal | F | May 23, 2024, 3:06 a.m. | OK | C++20 (GCC 13-64) | TESTS | 39 | 702 | 63692800 | 3100 | |
263056691 | teraqqq | F | May 28, 2024, 7:06 p.m. | OK | C++20 (GCC 13-64) | TESTS | 39 | 811 | 29286400 | 3100 | |
262303596 | batchunikhil | F | May 23, 2024, 6:55 p.m. | OK | C++20 (GCC 13-64) | TESTS | 39 | 811 | 63795200 | 3100 | |
262230867 | luogu_bot3 | F | May 23, 2024, 9 a.m. | OK | C++20 (GCC 13-64) | TESTS | 39 | 812 | 63795200 | 3100 | |
263687274 | Kuroni | F | June 2, 2024, 12:05 a.m. | OK | C++20 (GCC 13-64) | TESTS | 39 | 827 | 60825600 | 3100 | |
263371784 | DAR5EID | F | May 30, 2024, 5:53 p.m. | OK | C++20 (GCC 13-64) | TESTS | 39 | 827 | 63897600 | 3100 | |
261735100 | sifey | F | May 20, 2024, 7:20 a.m. | OK | C++20 (GCC 13-64) | TESTS | 39 | 858 | 63795200 | 3100 | |
262841675 | nguyenquocthao00 | F | May 27, 2024, 7:18 a.m. | OK | Go | TESTS | 39 | 843 | 48844800 | 3100 | |
261785024 | kl_2200031074 | F | May 20, 2024, 1:19 p.m. | OK | Java 21 | TESTS | 39 | 1811 | 128307200 | 3100 | |
261722013 | dzhi | F | May 20, 2024, 4:45 a.m. | OK | Java 21 | TESTS | 39 | 1875 | 128000000 | 3100 | |
261759962 | timiss | F | May 20, 2024, 9:55 a.m. | OK | Java 21 | TESTS | 39 | 1889 | 141414400 | 3100 | |
262188912 | strashila | F | May 22, 2024, 7:32 p.m. | OK | PyPy 3-64 | TESTS | 39 | 4624 | 154931200 | 3100 |
Back to search problems