ICode9

精准搜索请尝试: 精确搜索
  • 152. 乘积最大子数组2022-09-12 23:03:42

    152. 乘积最大子数组 给你一个整数数组 nums ,请你找出数组中乘积最大的非空连续子数组(该子数组中至少包含一个数字),并返回该子数组所对应的乘积。 测试用例的答案是一个 32-位 整数。 子数组 是数组的连续子序列。   示例 1: 输入: nums = [2,3,-2,4] 输出: 6 解释: 子数组

  • CodeTON Round 2 (Div. 1 + Div. 2, Rated, Prizes!) (A——D)2022-08-01 17:02:44

    A. Two 0-1 Sequences 题意:从a数组的第一个和第二个元素中挑选一个元素留下来,另外一个丢掉。可以反复进行此操作。问最终a数组能否等于b数组。 思路: 注意,操作只能在第一个元素和第二个元素中进行。也就是说,一旦能删的删完了,a数组还不能等于b数组,那就是NO。 否则,从后往前看。如果b

  • 模拟专题2022-07-02 23:06:53

    1095 Cars on Campus Link 配对要求是,如果一个车多次进入未出,取最后一个值;如果一个车多次out未进入,取第一个值。 注意:一个车可能出入校园好多次,停车的时间应该取之和 #include <iostream> #include <cstdio> #include <cstdlib> #include <algorithm> #include <string> #include

  • [AcWing 11] 背包问题求方案数2022-06-21 00:34:34

    点击查看代码 #include<iostream> #include<cstring> using namespace std; const int N = 1010, mod = 1e9 + 7; int n, m; int f[N], g[N]; int main() { cin >> n >> m; memset(f, -0x3f, sizeof f); f[0] = 0; g[0] = 1; for (int i = 1; i <

  • [AcWing 272] 最长公共上升子序列2022-06-18 00:01:42

    点击查看代码 #include<iostream> using namespace std; const int N = 3010; int n; int a[N], b[N]; int f[N][N]; int main() { cin >> n; for (int i = 1; i <= n; i ++) cin >> a[i]; for (int i = 1; i <= n; i ++) cin >> b[i]; for (

  • PAT Advanced Level 1003 Emergency2022-04-25 08:01:01

    原题传送门 1. 问题描述 2. Solution 题意 给出N个城市,M条无向边。每个城市中都有一定数目的救援小组,所有边的边权已知。现在给出起点和终点,求从起点到终点的最短路径条数及最 短路径上求援小组数目之和。如果有多条最短路径,则输出数目之和最大的。 样例解释 如图10-35所示,每个点

  • P2216 [HAOI2007]理想的正方形2022-04-02 13:33:35

    题面 有一个 \(a \times b\) 的整数组成的矩阵,现请你从中找出一个 \(n \times n\) 的正方形区域,使得该区域所有数中的最大值和最小值的差最小。 输入格式 第一行为 \(3\) 个整数,分别表示 \(a,b,n\) 的值。 第二行至第 \(a+1\) 行每行为 \(b\) 个非负整数,表示矩阵中相应位置上的数

  • 蓝桥杯[十一届][B组]-等差数列2022-03-31 23:33:20

         题目比较简单,但是考察一些数学知识。 #include<bits/stdc++.h> #include<string.h> using namespace std; int num[100005]={0}; int cmp(const void* a,const void* b){ return *(int*)a-*(int*)b; } int main(){ ios::sync_with_stdio(false), cin.tie(0);

  • P4933 大师2022-03-30 20:33:25

    传送门 以公差作为状态转移的一维(没见过),状态转移方程为: dp[ i ][ a[ i ] - a[ j ] ] = Σ(dp[ j ][ a[ i ] - a[ j ] ] + 1)j < i 又因为公差可能为负数,因此在公差上要加上偏移量来实现负数数组,如[ a[ i ] - a[ j ] + maxv ]。 #include<iostream> #define MAXN 1010 #define MAXV

  • 1072. Gas Station (30)(Dijkstra)2022-02-16 23:00:38

    A gas station has to be built at such a location that the minimum distance between the station and any of the residential housing is as far away as possible. However it must guarantee that all the houses are in its service range. Now given the map of the

  • 1018. Public Bike Management (30)(Dijkstra + DFS)2022-02-14 22:01:45

    There is a public bike service in Hangzhou City which provides great convenience to the tourists from all over the world. One may rent a bike at any station and return it to any other stations in the city. The Public Bike Management Center (PBMC) keeps mo

  • 【死亡笔记☠】线段树历史区间最值小记2022-02-02 20:02:56

    线段树历史区间最值:支持区间加法,询问区间内历史上的最大值,清空历史 不要草率!!!比看上去的要难无数倍!!! 注意事项: 1. 一定要记录两个标记 $tag$ 和 $mxtag$,分别为“区间加标记”和“区间最大加标记”(后者也可以理解为这个区间内所有来过的加标记的前缀最大值) 2. 正确的 pushdown 方法:

  • 【2021CCPC女生赛】E. 被遗忘的计划2022-01-23 22:33:31

    Gym-103389E 注意这题价值和价格不要搞混,vp的时候还以为是价值模n... k个都取价值最大的物品maxv,和就是f中的最大值maxf,k的唯一可能取值maxf/maxv 得出的k不在[1,1e9]或快速幂求出 v 数组的循环卷积的 k 次幂后不等于f数组说明无解 循环卷积:这个其实就是多项式乘法,这道题目以v

  • 连续最大子数组和2022-01-03 20:01:15

    一,一个记录当前子数组和,一个记录最大子数组和 1 class Solution { 2 public: 3 int FindGreatestSumOfSubArray(vector<int> array) { 6 int cur = array[0]; 7 int maxv=array[0]; 8 for (int i=1; i<array.size(); ++i) { 9 if

  • C++ 最长公共子数组2022-01-01 11:06:33

    //给定两个整数数组,求两个数组的最长的公共子数组的长度。子数组是连续的,比如[1, 3, 5, 7, 9]的子数组有[1, 3],[3, 5, 7]等等,但是[1, 3, 7]不是子数组 //数据范围:两个数组的长度都满足1-1000,数组中的值都满足0-100 //关键是动态规划,本例子优化了缓冲的大小,但还是没有

  • 强化阶段 Day 22 算法笔记 10.3 图的遍历2021-12-31 19:59:43

    目录 1.Head of a Gang 2.邻接矩阵版bfs 3.邻接表 4.带层号 5.Forwards on Weibo 1.Head of a Gang #include<cstdio> #include<vector> #include<cstring> #include<string> #include<stack> #include<set> #include<map> #include<ctime&

  • 2021.12.11模拟总结2021-12-17 22:34:14

    今天进行了第二次模拟,总的来说表现还可以。最后九道题得分:560. 头一次用996,可以实时看到每道题得分,雀食不错。   排序的专题 3、众数(masses) 【问题描述】 由文件给出N个1到30000 间无序数正整数,其中 1≤N≤10000,同一个正整数可能会出现多次,出现次数最多的整数称为众数。求出它

  • PAT甲级2020秋季2021-11-29 14:33:51

    PAT甲级2020秋季 //01 #include <iostream> #include <set> #include <algorithm> #include <vector> #include <unordered_map> #include <cmath> #include <cstring> using namespace std; int n, m, k; int lw[10009]; int milkl

  • Leetcode152:乘积最大子数组(动态规划,维护两个状态表)2021-11-17 19:32:06

          来源 1 class Solution { 2 public int maxProduct(int[] nums) { 3 int n = nums.length; 4 int[] maxV = new int[n]; 5 int[] minV = new int[n]; 6 maxV[0] = nums[0]; 7 minV[0] = nums[0]; 8 int r

  • CF1553H2021-11-16 21:02:44

    一种套路是考虑对相差较少的数进行统计,不过在这题并没有什么用。 另一种思考方式是这样的:考虑对位数作为状态进行dp,显然若 \(x\) 与 \(a_i,a_j\) 最高几位都相同的话他们相减显然比较优(或者说这是比较优的情况的子集:\(a_i,a_j\) 最高几位相同),那么就从低位开始枚举,需要设3个量:\(min

  • poj 1547(水题)2021-11-10 09:02:51

    #include<iostream> using namespace std; int main(){ int n; int x,y,z,data[10]; char name[10][10]; int maxv,minv,maxi,mini; while(scanf("%d",&n)==1&&n!=-1){ maxv = -1; minv = 9999; for

  • 线性DP2021-11-09 21:35:45

    线性DP(部分) 例:aw272 LCIS 272. 最长公共上升子序列 - AcWing题库 思路分析: 题目是LCS与LIS的结合,那么我们显然可以结合两道经典例题的思路, 定义f[i] [j] 表示,在a[1...i] 与 b[1...j] 中出现的以B[j]为结尾的数字。 随后我们先遍历a[i],再遍历b[j], 接下来分两种情况讨论, ①如果a[

  • hdu 2795 Billboard -- 线段树2021-10-15 21:34:23

    hdu 2795 Billboard 以h建立线段树维护最大值每个节点初始化最大值为w 对于每次改,从最左端开始找满足要求的位置 //#include<bits/stdc++.h> #include<iostream> #include<vector> //#include <unordered_map> using namespace std; //template<class...Args> //void debug(A

  • P3371 【模板】单源最短路径(弱化版)2021-10-07 22:02:48

    题目背景 本题测试数据为随机数据,在考试中可能会出现构造数据让SPFA不通过,如有需要请移步 P4779。 题目描述 如题,给出一个有向图,请输出从某一点出发到所有点的最短路径长度。 输入格式 第一行包含三个整数 n,m,sn,m,s,分别表示点的个数、有向边的个数、出发点的编号。 接下来

  • 3. 无重复字符的最长子串2021-09-16 12:05:35

    3. 无重复字符的最长子串 题目 3. 无重复字符的最长子串题目 方法思路 1. 滑动窗口+hashMap hashMap记录元素和位置的对应信息滑动窗口的右指针不断向右侧扩展hashMap记录区间[l, r)中元素的位置信息如果r扩展时某个元素出现过(在hashMap中存在)并且它的位置在[l, r)中,说明出现

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有