随笔分类 - 算法
记录 acm 算法学习过程中的点点滴滴
摘要:Description Given an integer array nums and an integer k, return the maximum sum of a non-empty subsequence of that array such that for every two cons
阅读全文
摘要:Description You are given the array nums consisting of n positive integers. You computed the sum of all non-empty continuous subarrays from the array
阅读全文
摘要:Description You are given a list of non-negative integers, a1, a2, ..., an, and a target, S. Now you have 2 symbols + and -. For each integer, you sho
阅读全文
摘要:description Given an array of integers A, consider all non-empty subsequences of A. For any sequence S, let the width of S be the difference between t
阅读全文
摘要:Description Given an array of integers A, find the number of triples of indices (i, j, k) such that: 0 <= i < A.length 0 <= j < A.length 0 <= k < A.le
阅读全文
摘要:Description You want to schedule a list of jobs in d days. Jobs are dependent (i.e To work on the i-th job, you have to finish all the jobs j where 0
阅读全文
摘要:Description Given an array of integers cost and an integer target. Return the maximum integer you can paint under the following rules: The cost of pai
阅读全文
摘要:Description Given a string S and a string T, count the number of distinct subsequences of S which equals T. A subsequence of a string is a new string
阅读全文
摘要:Description In a given array nums of positive integers, find three non-overlapping subarrays with maximum sum. Each subarray will be of size k, and we
阅读全文
摘要:Description Your car starts at position 0 and speed +1 on an infinite number line. (Your car can go into negative positions.) Your car drives automati
阅读全文
摘要:一开始准备用二维 DP 来做,但是发现不好写。看了别人用了 height 数组解决此题,后面写了上述题解。
阅读全文
摘要:我用的是二维 dp, 有人给出了 一维 dp 解法
阅读全文
摘要:dp 题目的边界初始值还是很难考虑的, 如果我不用 s, p = 'a' + s, 'a' + p 来预处理一下。真不知道怎么写初始化值!
阅读全文
摘要:调了一天,囧!第一次写 lazy 更新线段树,结果在查询和 add 时没有考虑到我用了区间 lazy 更新。后面在增加 lazy 更新处理代码时,将 bitmap 作为 color 传进去。导致 add 函数逻辑不正确。 本题还有一个坑,要考虑输入参数的大小。L 参数可能比 R 参数大!!
阅读全文
摘要:之前用树状数组做这道题,没发现有什么问题。用线段数组后,总是报 runtime Error。后来发现是数组开小了。 include include include include using namespace std; const int maxn = 500010; struct Num { i
阅读全文
摘要:Intro 题目地址 http://poj.org/problem?id=3321, 我的遍历算法提交上去居然 TLE 了。poj 网站也没有告诉我用了多少秒,这样我就没办法知道我和别人的差距。也找不到测试数据集来自测,只好写个 python 程序来生成测试数据集。 !/usr/bin/env py
阅读全文
摘要:Basic Topic Intro 线段树:本质上将每个局部的计算结果保留下来,在需要的时候通过少量的操作就可以获取到最终的结果。因为 2 分组合是最佳的方式, 所以用二叉树建立线段树 目前遇到的线段树分为 2 种:一种按照输入数据的值域来建的树, 另外一种按照输入数据的个数(即位置) 线段树适合解
阅读全文

浙公网安备 33010602011771号