随笔分类 -  数据结构-二分

摘要:C 问删掉在数组中一个数后,剩下的数组中,是否存在一个数时其它所有数的和。 遍历每一个数,假设删掉它后,剩下的数中取一个最大值,看他的值是不是数组之和的一半,是的话就成立。 D 有一个数组,可以选定一个子集,看最大能删除多少次,输出那个子集。 二分,检查当前最大删除次数时m时,是否成立。 E 有很多 阅读全文
posted @ 2018-11-17 12:00 starry_sky 阅读(224) 评论(0) 推荐(0)
摘要:有N个岛连在一起形成了一个大的岛屿,如果海平面上升超过某些岛的高度时,则这个岛会被淹没。原本的大岛屿则会分为多个小岛屿,如果海平面一直上升,则所有岛都会被淹没在水下。 给出N个岛的高度。然后有Q个查询,每个查询给出一个海平面的高度H,问当海平面高度达到H时,海上共有多少个岛屿。例如: 岛屿的高度为: 阅读全文
posted @ 2018-09-02 10:38 starry_sky 阅读(256) 评论(0) 推荐(0)
摘要:Problem Description There is an apple tree in front of Taotao's house. When autumn comes, n apples on the tree ripen, and Taotao will go to pick these 阅读全文
posted @ 2018-08-16 19:57 starry_sky 阅读(460) 评论(0) 推荐(0)
摘要:A. Remove Duplicates Petya has an array aa consisting of nn integers. He wants to remove duplicate (equal) elements. Petya wants to leave only the rig 阅读全文
posted @ 2018-05-13 20:08 starry_sky 阅读(831) 评论(0) 推荐(0)
摘要:A. Aramic script In Aramic language words can only represent objects. Words in Aramic have special properties: A word is a root if it does not contain 阅读全文
posted @ 2018-05-13 12:18 starry_sky 阅读(361) 评论(0) 推荐(0)
摘要:B. Levko and Array standard output B. Levko and Array standard output Levko has an array that consists of integers: a1, a2, ... , an. But he doesn’t l 阅读全文
posted @ 2018-04-22 11:59 starry_sky 阅读(214) 评论(0) 推荐(0)
摘要:E. Maximum Subsequence You are given an array a consisting of n integers, and additionally an integer m. You have to choose some sequence of indices b 阅读全文
posted @ 2017-11-11 16:51 starry_sky 阅读(221) 评论(0) 推荐(0)
摘要:1094 和为k的连续区间 一整数数列a1, a2, ... , an(有正有负),以及另一个整数k,求一个区间[i, j],(1 <= i <= j <= n),使得a[i] + ... + a[j] = k。 Input Output Input示例 Output示例 阅读全文
posted @ 2017-10-01 00:33 starry_sky 阅读(402) 评论(0) 推荐(0)
摘要:DESCRIPTION 给你一个01串,我们定义这个串的咸鱼值,是最长的全1串。现在你最多可以使用K次咸鱼魔法,每次魔法,你可以使得一个位置翻转(0变成1,1变成0)。问你这个串的咸鱼值最多是多少。 DESCRIPTION 给你一个01串,我们定义这个串的咸鱼值,是最长的全1串。现在你最多可以使用K 阅读全文
posted @ 2017-07-21 17:07 starry_sky 阅读(218) 评论(0) 推荐(0)
摘要:1257 背包问题 V3 N个物品的体积为W1,W2......Wn(Wi为整数),与之相对应的价值为P1,P2......Pn(Pi为整数),从中选出K件物品(K <= N),使得单位体积的价值最大。 N个物品的体积为W1,W2......Wn(Wi为整数),与之相对应的价值为P1,P2..... 阅读全文
posted @ 2017-07-18 12:34 starry_sky 阅读(179) 评论(0) 推荐(0)
摘要:Sagheer and Nubian Market 二分+排序 比赛时没对,赛后检查才发现check()里的参数类型是int 改成ll就对了。好气哦! 阅读全文
posted @ 2017-06-02 12:44 starry_sky 阅读(184) 评论(0) 推荐(0)
摘要:题目描述 给定2个数组a、b以及一个整数x 判断是否存在a[i]+b[j]=x 输入 第一行:两个整数n、m (1<n、m<10000) 第二行:n个整数,为数组a 第三行:m个整数,为数组b 第四行:一个整数k (1<k<20),表示k次查询 接下来的k行:每行一个整数x 输出 若数组a中存在一个 阅读全文
posted @ 2017-03-12 11:49 starry_sky 阅读(152) 评论(0) 推荐(0)