1220

又一神题啊  卡内存可以卡到这种地步 省得不行了

开两个【N]数组 一个来记录前驱  一个存数 记录前驱的用unsigned short类型 最大可达65535 不过可以标记一下是否比这个数大  比它大的话就减去 求的时候再加上

 #include <iostream>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<cstdio>
using namespace std;
#define N 100010
unsigned short p2[N];
int p1[N];
int stack[];
int main()
{
int n,a,b,g=;
char s[];
scanf("%d",&n);
while(n--)
{
scanf("%s",s);
if(strcmp(s,"PUSH")==)
{
scanf("%d%d%*c",&a,&b);
p1[g] = b;
if(stack[a]>=)
{
p2[g] = stack[a]-;
p1[g] = -p1[g];
}
else
p2[g] = stack[a];
stack[a] = g;
g++;
}
else
{
scanf("%d%*c",&a);
printf("%d\n",abs(p1[stack[a]]));
if(p1[stack[a]]<)
stack[a] = p2[stack[a]]+;
else
stack[a] = p2[stack[a]];
}
}
return ;
}

1220. Stacks的更多相关文章

  1. [LeetCode] Implement Queue using Stacks 用栈来实现队列

    Implement the following operations of a queue using stacks. push(x) -- Push element x to the back of ...

  2. Leetcode Implement Queue using Stacks

    Implement the following operations of a queue using stacks. push(x) -- Push element x to the back of ...

  3. Device nodes and device stacks

    [Device nodes and device stacks] 链接:https://msdn.microsoft.com/en-us/library/windows/hardware/ff5547 ...

  4. 1220 - Mysterious Bacteria--LightOj1220 (gcd)

    http://lightoj.com/volume_showproblem.php?problem=1220 题目大意: 给你一个x,求出满足 x=b^p, p最大是几. 分析:x=p1^a1*p2^ ...

  5. 2016暑假多校联合---Joint Stacks (STL)

    HDU  5818 Problem Description A stack is a data structure in which all insertions and deletions of e ...

  6. openstack-kilo--issue(九) heat stacks topology中图形无法正常显示

    ======声明======= 欢迎转载:转载请注明出处 http://www.cnblogs.com/horizonli/p/6186581.html ==========环境=========== ...

  7. Implement Queue using Stacks

    Implement the following operations of a queue using stacks. push(x) -- Push element x to the back of ...

  8. Bitnami --https://bitnami.com/stacks

    Bitnami is an app store for server software. Install your favorite applications in your own servers ...

  9. poj 1220(短除法)

    http://poj.org/problem?id=1220 题意:进制转换,把a进制转换为b进制. 如果数据不大的话,那么这个题还是很简单的,但这个题就是数据范围太大,所以这里可以采用短除法来做. ...

随机推荐

  1. 一句话解释jquery中offset、pageX, pageY、position、scrollTop, scrollLeft的区别

    offset   元素相对文档的偏移 pageX, pageY 事件(鼠标)相对文档的偏移 注意:文档是指document, 而不是当前窗口,是包含了滚动位置的,即滚动条的位置对这些值是不产生影响的 ...

  2. 为云饰数据库添加Index

    Asset Collection: 1. _id_ 2. CategoryId_1_Date_-1 3. CategoryId_1_Id_1 4. CategoryId_1_Name_1 5. Cat ...

  3. ComboBox Control Messages 消息

    连接到MSDN,有时间完善这个.具体说明可点击进入msdn CB_ADDSTRING 添加一个字符串组合框的列表框.如果组合框没有cbs_sort风格,字符串添加到列表的结尾.否则,该字符串插入列表, ...

  4. Catalyst揭秘 Day5 optimizer解析

    Catalyst揭秘 Day5 optimizer解析 Optimizer是目前为止中catalyst中最重要的部分.主要作用是把analyzed logicalPlan变成optimized Log ...

  5. Android UI效果实现——滑动模糊渐变效果实现

    前言: 大家应该都看到过iOS7解锁屏幕的滑动模糊渐变效果,好了,现在可以把手纸收起来了,今天黄老师就给大家讲一下如何在Android平台上 实现类似的滑动模糊渐变效果,其实方式远比你想像的简单. 目 ...

  6. shell curl

    最近突然发现了一个有趣的问题:怎样判断日期是工作日还是节假日.(http://www.cnblogs.com/ZXdeveloper/p/4018886.html) 顺便发现了一个有用的网址:http ...

  7. 1076. Forwards on Weibo (30)

    时间限制 3000 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Weibo is known as the Chinese v ...

  8. linux驱动系列之tftp(转)

    转自网页:http://blog.csdn.net/xingyu19871124/article/details/7315893 最近在将做的嵌入式项目移植到ARM开发板上,宿主机用的ubuntu11 ...

  9. DataTableExtensions.AsEnumerable 方法

    在下面的示例中,DisplayProducts 方法接收一个数据表,其中包含名为 ProductName一个 DataColumn,提取 ProductName 值,然后输出值. using Syst ...

  10. coolcarousel 图片轮播缩放问题

    var myurl; var mydata; var mytype = "POST"; var jsonType = "json"; var htmlType ...