
栈和队列
文章平均质量分 57
UCAS王小二
不念过去,不畏未来...
展开
-
leetcode 1882. 使用服务器处理任务【优先队列】
原题链接给你两个 下标从 0 开始 的整数数组 servers 和 tasks ,长度分别为 n 和 m 。servers[i] 是第 i 台服务器的 权重 ,而 tasks[j] 是处理第 j 项任务 所需要的时间(单位:秒)。你正在运行一个仿真系统,在处理完所有任务后,该系统将会关闭。每台服务器只能同时处理一项任务。第 0 项任务在第 0 秒可以开始处理,相应地,第 j 项任务在第 j 秒可以开始处理。处理第 j 项任务时,你需要为它分配一台原创 2021-06-06 16:45:46 · 624 阅读 · 0 评论 -
poj 2082 Terrible Sets【单调栈】
Terrible Sets DescriptionLet N be the set of all natural numbers {0 , 1 , 2 , . . . }, and R be the set of all real numbers. wi, hi for i = 1 . . . n are原创 2017-09-14 22:07:17 · 261 阅读 · 0 评论 -
HDU 6215 Brute Force Sorting【双端链表】
题目链接; 题意:给出一个序列,从左到右扫一遍,每个数如果比左面相邻的小或者比右边相邻的大,就删掉,先不更新,最后扫过一遍统一更新,更新完后的序列重复操作,直至满足没有可以删除的项。 思路: 最开始想着维护一个K值(当前队列的顶端值),一遍扫过出答案,wa了。 根据题目模拟去写一遍一遍的去扫序列,用双端链表去更新序列,更新后重复操作,最后输出链表上的值。#include <cstdio>原创 2017-09-23 23:22:40 · 294 阅读 · 0 评论 -
codeforces 754D Fedor and coupons【优先队列+贪心*好题】
D. Fedor and couponstime limit per test4 secondsAll our characters have hobbies. The same is true for Fedor. He enjoys shopping in the neighboring supermarket.The goods in the supermarket have unique ...原创 2017-11-09 17:48:19 · 417 阅读 · 0 评论 -
Wannafly挑战赛13【A B C D】【逆元+数学+优先队列】
A zzy的小号 链接:https://www.nowcoder.com/acm/contest/80/A 来源:牛客网 题目描述 学家zzy根据字体的特点,创建了一系列小号… I_Love_Chtholly! 又到了打wannafly的时候,许许多多的大佬准备注册小号开始虐场,zzy也不例外,他发现他的电脑的字体有一个特点!某些不同的字符所显示的是一样的! ...原创 2018-04-08 14:17:46 · 387 阅读 · 0 评论 -
HDU 6301 Distinct Values【线段树||优先队列】
题意:给你一个区间[1,n][1,n][1,n],m个询问,每次询问[l,r][l,r][l,r],表示这段区间数字不相重,输出字典序最小的排列. 分析: 区间与区间的关系有三种:包含,相交,分离; 把包含区间段的可以去掉,只剩下两种。先按照左端排下序,用线段树维护填第i个位置的最小值,查询O(1)O(1)O(1),区间单点更新O(n∗lgn)O(n∗lgn)O(n*lgn).#incl...原创 2018-07-24 16:34:55 · 208 阅读 · 0 评论 -
POJ 2559 Largest Rectangle in a Histogram【单调栈】
题意:给你一堆紧挨着的高度不定,长度为1的矩形,让你求最大矩形面积. 分析: 用单调栈维护一个最长非递减序列,遇到不满足的情况,直接出栈并计算面积(这个面积以pop的高度为高度,长取最长).#include <cstdio>#include <algorithm>#include <cstring>#include <cmath>...原创 2018-08-02 10:05:56 · 177 阅读 · 0 评论 -
Codeforces Round #503 C Elections【优先队列+枚举】
题意:1号选举人想要赢的胜利,可以花钱买票得到最多的票; 分析: 先把vector排下序,再枚举获得的票数,用优先队列维护花费.#include <bits/stdc++.h>#include <math.h>#include <string.h>#include <algorithm>using namespace std;#...原创 2018-08-13 22:35:45 · 220 阅读 · 0 评论 -
zzuli 2172 GJJ的日常之购物【dp+优先队列】
Description一天,GJJ去购物,来到商场门口,GJJ计划要买n个商品,第i个商品的坐标为(xi,yi),重量是wi。 GJJ比较任性,想按照商品编号从小到大的顺序将所有的商品的搬到车里(车在(0,0)的位置); GJJ可以几个商品一起搬,但在任何时候GJJ手中的商品重量不能超过最大载重C。 商场的过道只有横着的和竖着的。求GJJ行走的最短距离(GJJ的起始位置为(0,0))。 In原创 2017-08-21 15:44:55 · 330 阅读 · 0 评论 -
1414: Kick Ass【栈+思维】
1414: Kick Ass [字符串]时间限制: 1 Sec 内存限制: 128 MB提交: 105 解决: 27 统计题目描述你玩过一个叫做"Kick Ass - Destroy the web"的游戏吗?如果你想玩的话请点击此处当然,你没有玩过也没关系,这个游戏是通过js来加载一个飞船,让你可以通过控制它发射子弹来摧毁网页上的元素,从而获得分数。原创 2017-08-12 16:04:08 · 503 阅读 · 0 评论 -
Replace To Make Regular Bracket Sequence(括号匹配)
You are given string s consists of opening and closing brackets of four kinds, {},[], (). There are two types of brackets: opening and closing. You can replace any bracket by another of the same t原创 2017-01-23 20:50:51 · 563 阅读 · 0 评论 -
Windows Message Queue(优先队列)
Message queue is the basic fundamental of windows system. For each process, the system maintains a message queue. If something happens to this process, such as mouse click, text change, the system wil原创 2017-01-23 21:14:17 · 1040 阅读 · 0 评论 -
hdu 1873 看病要排队(优先队列)
看病要排队这个是地球人都知道的常识。 不过经过细心的0068的观察,他发现了医院里排队还是有讲究的。0068所去的医院有三个医生(汗,这么少)同时看病。而看病的人病情有轻重,所以不能根据简单的先来先服务的原则。所以医院对每种病情规定了10种不同的优先级。级别为10的优先权最高,级别为1的优先权最低。医生在看病时,则会在他的队伍里面选择一个优先权最高的人进行诊治。如果遇到两个优先权一样的病人的话原创 2017-01-23 21:18:24 · 383 阅读 · 0 评论 -
51nod1289 栈+模拟
1289 大鱼吃小鱼题目来源: Codility基准时间限制:1 秒 空间限制:131072 KB 分值: 5 难度:1级算法题 收藏 关注有N条鱼每条鱼的位置及大小均不同,他们沿着X轴游动,有的向左,有的向右。游动的速度是一样的,两条鱼相遇大鱼会吃掉小鱼。从左到右给出每条鱼的大小和游动的方向(0表示向左,1表示向右)。问足够长的原创 2017-05-03 16:25:55 · 240 阅读 · 0 评论 -
poj 2367 Genealogical tree【简单拓扑+队列】
Genealogical treeTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 5727 Accepted: 3756 Special JudgeDescriptionThe system of Martians' blood relations原创 2017-07-21 09:38:04 · 268 阅读 · 0 评论 -
hdu 2066 一个人的旅行【vector优化】
一个人的旅行Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 38597 Accepted Submission(s): 13104Problem Description虽然草儿是个路痴(就是在杭电待了一原创 2017-07-23 12:26:24 · 329 阅读 · 0 评论 -
LightOJ - 1141【bfs+分解质因子】
In this problem, you are given an integer number s. You can transform any integer number A to another integer number B by adding x to A. This x is an integer number which is a prime factor of A (please原创 2017-08-01 18:11:39 · 365 阅读 · 0 评论 -
poj 1383 Labyrinth【bfs+队列】
LabyrinthTime Limit: 2000MS Memory Limit: 32768KTotal Submissions: 4184 Accepted: 1564DescriptionThe northern part of the Pyramid contains a very large and原创 2017-08-04 12:26:15 · 335 阅读 · 0 评论 -
hdu 1702 ACboy needs your help again!(模板)
ACboy was kidnapped!! he miss his mother very much and is very scare now.You can't image how dark the room he was put into is, so poor :(.As a smart ACMer, you want to get ACboy out of the monst原创 2017-01-23 20:58:51 · 580 阅读 · 0 评论