随笔分类 -  思维

摘要:Vladik had started reading a complicated book about algorithms containing n pages. To improve understanding of what is written, his friends advised hi 阅读全文
posted @ 2019-01-17 23:11 茄子Min 阅读(286) 评论(0) 推荐(0)
摘要:Vasya has an array a consisting of positive integer numbers. Vasya wants to divide this array into two non-empty consecutive parts (the prefix and the 阅读全文
posted @ 2019-01-16 15:48 茄子Min 阅读(361) 评论(0) 推荐(0)
摘要:There are nn segments [li,ri][li,ri] for 1≤i≤n1≤i≤n. You should divide all segments into two non-empty groups in such way that there is no pair of seg 阅读全文
posted @ 2019-01-12 13:51 茄子Min 阅读(933) 评论(2) 推荐(0)
摘要:You are given qq queries in the following form: Given three integers lili, riri and didi, find minimum positive integer xixi such that it is divisible 阅读全文
posted @ 2019-01-12 13:25 茄子Min 阅读(578) 评论(0) 推荐(0)
摘要:Pasha is participating in a contest on one well-known website. This time he wants to win the contest and will do anything to get to the first place! T 阅读全文
posted @ 2019-01-11 17:39 茄子Min 阅读(279) 评论(0) 推荐(0)
摘要:You are given an integer sequence 1,2,…,n1,2,…,n. You have to divide it into two sets AAand BB in such a way that each element belongs to exactly one  阅读全文
posted @ 2019-01-11 12:30 茄子Min 阅读(701) 评论(0) 推荐(0)
摘要:You are given a string ss consisting of exactly nn characters, and each character is either '0', '1' or '2'. Such strings are called ternary strings. 阅读全文
posted @ 2019-01-11 00:11 茄子Min 阅读(546) 评论(0) 推荐(0)
摘要:You are policeman and you are playing a game with Slavik. The game is turn-based and each turn consists of two phases. During the first phase you make 阅读全文
posted @ 2019-01-10 23:42 茄子Min 阅读(648) 评论(0) 推荐(0)
摘要:A few years ago Sajjad left his school and register to another one due to security reasons. Now he wishes to find Amir, one of his schoolmates and goo 阅读全文
posted @ 2019-01-09 21:10 茄子Min 阅读(288) 评论(0) 推荐(0)
摘要:In the beginning of the new year Keivan decided to reverse his name. He doesn't like palindromes, so he changed Naviek to Navick. He is too selfish, s 阅读全文
posted @ 2019-01-09 21:01 茄子Min 阅读(259) 评论(0) 推荐(0)
摘要:Tavak and Seyyed are good friends. Seyyed is very funny and he told Tavak to solve the following problem instead of longest-path. You are given l and  阅读全文
posted @ 2019-01-09 20:50 茄子Min 阅读(291) 评论(0) 推荐(0)
摘要:题目链接 题意有点坑: 给你一个N*N的矩阵,让你填入K个1,使之整个矩阵关于左上到右下的对角线对称,并且这个要求这个矩阵的字典序最大。 对矩阵的字典序的定义是从每一行的第一个元素开始比较,大着为字典序较大。 思路: 根据字典序的定义贪心的从第一个元素开始走,如果没被填1,就填1并且关于对角线的对称 阅读全文
posted @ 2019-01-08 17:21 茄子Min 阅读(308) 评论(0) 推荐(0)
摘要:题目链接 这是一道很棒的二分题。 思路: 首先先思考什么情况下是可以无限的使用,即输出-1. 我们思考可知,如果每一秒内所有设备的用电量总和小于等于充电器每秒可以充的电,那么这一群设备就可以无限使用。 接下来分析不是无限使用的情况: 题目要求的是满足某个情况的最大值。 很像二分的类型,二分题目往往就 阅读全文
posted @ 2019-01-08 00:54 茄子Min 阅读(283) 评论(0) 推荐(0)