![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
codeforces
文章平均质量分 51
ZustinLau
I am currently studying Economics at the Chinese University of Hong Kong and I am interested in data structure and algorithms.
展开
-
CF797E
關於E題, 我本來想著 把所有數字取模後排序, 然後二分找答案, 但是因為每次選擇某個數字後的刪除操作 需要用O(n), 就不知道怎麼實現了. 而且還可以用二分去找匹配的剩餘價值.原來有multiset這個好工具, 基本能自動排序, 和支持刪除操作, stl大法好, 而且還支持lowerbound 和upperbound 操作,實在方便, erase 操作, 會一次性把所有等於那個數值的東西刪除, 我們只需要刪除用了那個數, 所以每次拿begin()的位置, 然後刪除begin()的位置, 拿了的數字原创 2022-06-08 14:28:22 · 89 阅读 · 0 评论 -
CF1673C - Palindrome Basis
背包問題原创 2022-06-03 14:44:23 · 106 阅读 · 0 评论 -
CF189A (Complete Knapsack DP)
Polycarpus has a ribbon, its length isn. He wants to cut the ribbon in a way that fulfils the following two conditions:After the cutting each ribbon piece should have lengtha,borc. After the cutting the number of ribbon pieces should be maximum.H...原创 2022-05-20 11:16:08 · 115 阅读 · 0 评论 -
CF230B. T-primes (Number Theory)
We know that prime numbers are positive integers that have exactly two distinct positive divisors. Similarly, we'll call a positive integertТ-prime, ifthas exactly three distinct positive divisors.You are given an array ofnpositive integers. For e...原创 2022-05-20 10:17:41 · 213 阅读 · 0 评论 -
1676F - Longest Strike
Given an arrayaaof lengthnnand an integerkk, you are tasked to find any two numbersllandrr(l≤rl≤r) such that:For eachxx(l≤x≤r)(l≤x≤r),xxappears inaaat leastkktimes (i.e.kkor more array elements are equal toxx). The valuer−lr−lis m...原创 2022-05-17 08:27:57 · 569 阅读 · 0 评论 -
CF774G Perfectionist Arkadiy
思維和構造題題目給定 h,w 和 a,需要我們找出最小的x,其中h,w,a都是整數。對於row和col 的a 都是比x 小一個的,我們嘗試自己加一個a,讓題目變的簡單一點。我們把橫軸上 a 的數量設為 n, 豎軸上的a的數量設為m。那麼新的 h w 和 a x 的關係式就變為,h 和 a 是整數 所以h + a 是整數,並且a + x 是h + a 和 w + a 的公因數,姑且把a + x 記為k則有x不可能是負數,所以k 至少要大於a。那麼我們原创 2022-03-12 19:39:47 · 71 阅读 · 0 评论 -
CF527D Clique Problem
題目要求找出圖的最大團,題目給定x 和 w,而對兩個頂點是否有邊取決於以下公式。最大團為兩兩有邊的頂點的集合。思路如果我們把 x 理解為水平線上的一個點,而 w 就是他半徑,那麼題目所定義的有邊就是說兩個點的半徑不可以有重疊。那麼這樣的話題目就很好做了,因為直接轉化為區間覆蓋問題了,我們把每個 x 的最左和最右點都存起來,然後排序,因為我們要找不重疊所以我們按照右端點進行排序,如果一樣就按照左端點排序,然後從小到大排序,每次把左端點跟右端點進行比較,如果新的左端點比有端點要大或者原创 2022-03-12 16:37:59 · 41 阅读 · 0 评论 -
CF482A Diverse Permutation
CodeForces 題解總數 1原创 2022-03-11 09:12:02 · 53 阅读 · 0 评论