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. WebApi传递JSON参数

    开发过程中经常进行JSON的传递,在WebApi中传递JSON字串时,会发现服务器端接收到不参数值,看下面代码 服务端: public void Post([FromBody]string value ...

  2. Jquery 控件

    1. Jeditable 2. Select2 3. superfish 4. Jquery file upload https://blueimp.github.io/jQuery-File-Upl ...

  3. php安全设定

    nginx: 在配置文件nginx.conf的http段里加入  server_tokens off;  HTTPD.CONFTraceEnable Off <Directory ~ " ...

  4. Android UI学习1:控件和基本事件的响应

    在任何一个 GUI 系统中,控制界面上的控件(通常称为控件)都是一个基本的内容.对于 Android 应用程序,控件称为 View. 在 Android 中,在处理 UI 中的各种元素的时候,两个程序 ...

  5. 《WPF程序设计指南》读书笔记——第7章 Canvas

    1.Canvas面板 using System; using System.Windows; using System.Windows.Controls; using System.Windows.M ...

  6. 关于对db_block_gets的理解与实验

    实验 一. 自己手动创建的小表 创建一个区大小为  40k  SYS@ORCL>show parameter db_block_size NAME                         ...

  7. RedHat6.4 用UDEV配置ASM所需磁盘

    同事在装一套RAC测试环境,结果发现原来用ASMLIB来配置磁盘,在安装GRID的时候,最终报错了,经过检查发现居然两边的磁盘不匹配.A机的sdb,sdc分别对应OCRVOL1,OCRVOL2,但是B ...

  8. jmeter测试本地myeclips调试状态下的tomcat程序死锁

    在myeclipse调试状态下的tomcat程序,用jmeter测试,居然发生死锁,调试两天无果,直接运行tomcat而不通过myeclipse,无死锁,真是又好气又好笑..

  9. flex toolTip样式设置

        需要3个文件.一个是样式类,一个样式文件,一个是mxml文件. ●MyToolTip.as package{ import mx.core.UITextField; import mx.ski ...

  10. PAT-乙级-1039. 到底买不买(20)

    1039. 到底买不买(20) 时间限制 100 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 CHEN, Yue 小红想买些珠子做一串自己喜欢的珠串 ...