[F] It Is Cold

Dr. Ziad Najem is known as the godfather of  the  ACPC. When the regional contest was held in 
Alexandria, Egypt, the weather was very cold. What surprised Dr. Ziad was that in the contest hall 

the fans were turned on! Dr. Ziad immediately needed to know, for each team, the speed in which 

the air reached that team.

Each team has N fans placed on a straight line to its right. Each fan i has a speed Si and direction Ci. 

Directions are either towards the team "T" or away from the team "A".

If two fans face the same direction, their speeds add up in the same direction. E.g.

Fan 1 Fan 2 Result

Direction T T T

Speed 2 4 2+4 = 6

If two fans face each other, their speeds cancel out. E.g.

Fan 1 Fan 2 Result

Direction A T T

Speed 2 4 4-2 = 2


Input Specification

The first line of input contains an integer T, the number of teams. For each team, you will be given 

an integer N, the number of fans. Two lines follow; the first line contains N space separated integers

Si, the speed of the air produced by fan i (0<= i < N). The second line contains N characters that 

describe the direction of the fans Ci (as described above).

T <= 100

0 < N <= 1000

0 <= Si <= 1000000000


Output Specification

There should be T lines, containing a single integer S each that represents the speed in which the air

reaches the team. S is zero if no air reaches the team.

有时候咧,题目都是不难滴,就是看你运气好不好,运气好的一想就到点子上,运气不好的咯,妹的纠结的半死不活都还是只能干瞪眼

这个题吧题意大概就是从距离你由近到远输入风的强度,然后再输入风的方向,A表示背向你而去,T表示面向你而来,然后你计算最后吹向你的风的强度,风的强度可以叠加跟削减,这是重点哦!!

#include <iostream>
#include <cstdio>
using namespace std;
int main (void)
{
    int t,n,m,i,j,k,l,a[1111];
    char c;
    __int64 S,A;  //用S标记当前我收到的风的强度,A标记离我而去的强度,因为后面的吹向我的风要抵消了这个强度才能到我这里,没抵消的话不关我屁事
    cin>>t;
    while(t--&&cin>>n)
    {
        for(i=0;i<n;i++)cin>>a[i];  //把强度记录
        for(i=0,S=A=0;i<n;i++)
        {
            cin>>c;  //输入方向
            if(c=='T')  //面向我
            {
                if(A>0)  //如果还有没抵消的离我而去的风
                if(A>=a[i])A-=a[i];  //如果这个吹来的风吹不赢那个离我而去的风--!那么就削减一点点得了
                else S+=a[i]-A,A=0;  //不然就是吹来的风赢了,剩下的强度加上来,同时那个离我而去的算是抵消了,就要置零
                else S+=a[i];  //如果没有离我而去的风就直接让他吹我一脸得了
            }
            else A+=a[i];  //背向我而去的风就把强度加起来
        }
        printf("%I64d\n",S);
    }
    return 0;
}

经典的是背向我而去的风不会影响到“已经”吹到我身上的风,所以只要记录下来给更远地方吹向我的风消遣

HUNNU--湖师大--11407--It Is Cold的更多相关文章

  1. hunnu 11313 无重复元素序列的最长公共子序列转化成最长递增子序列 求法及证明

    题目:http://acm.hunnu.edu.cn/online/?action=problem&type=show&id=11313 湖师大的比赛,见我的另一篇水题题解,这里要说的 ...

  2. python瓦登尔湖词频统计

    #瓦登尔湖词频统计: import string path = 'D:/python3/Walden.txt' with open(path,'r',encoding= 'utf-8') as tex ...

  3. 华为云FusionInsight湖仓一体解决方案的前世今生

    摘要:华为云发布新一代智能数据湖华为云FusionInsight时再次提到了湖仓一体理念,那我们就来看看湖仓一体的来世今生. 伴随5G.大数据.AI.IoT的飞速发展,数据呈现大规模.多样性的极速增长 ...

  4. Rxjava cold/hot Observable

    create Observable分为cold以及hot两种,cold主要是静态的,每次subscribe都是从头开始互不干扰,而hot的在同一时刻获得的值是一致的 cold Observable 使 ...

  5. 为川师大女生支招 15年如何还200W

    就在昨儿一条新闻火遍全网,川师大21岁女生樊师贝发帖称,希望有人借她200万,为父母在城里买房15年还清,至于利息“可以用后半生来陪伴你”.她说,六旬父亲要负担家用,哥哥啃老,而她目前一分钱都还没挣到 ...

  6. hihoCoder 1425 : What a Beautiful Lake(美丽滴湖)

    hihoCoder #1425 : What a Beautiful Lake(美丽滴湖) 时间限制:1000ms 单点时限:1000ms 内存限制:256MB Description - 题目描述 ...

  7. OpenStack nova VM migration (live and cold) call flow

    OpenStack nova compute supports two flavors of Virtual Machine (VM) migration: Cold migration -- mig ...

  8. 一塔湖图(codevs 1024)

    题目描述 Description 小松所在的PK大学校园又称作燕园,是一个十分美丽的校园.有博雅塔,未名湖,亚洲最大的高校图书馆,人称“一塔湖图”.但是由于燕园的历史比较悠久,所以很多的老房子都要不断 ...

  9. a cold welcome

    What does 'a cold welcome' refer to? On wednesday evening,we went to the town hall. It was the last ...

随机推荐

  1. js获取时间天数

    date2必须大于date1 function getDays(date1,date2){ /*获取之间的天数*/ /*date1,date2都是date格式*/ var getd=(date2.ge ...

  2. Ajax跨域访问问题-方法大全

    Case I. Web代理的方式 (on Server A) 即用户访问A网站时所产生的对B网站的跨域访问请求均提交到A网站的指定页面,由该页面代替用户页面完成交互,从而返回合适的结果.此方案可以解决 ...

  3. linux 备份日志文件

    seo说要备份文件,然后自己搞不定,每天一份文件.写了个shell,加了个crontab -e任务.每天执行一次. crontab: 59 23 * * * /root/sh/dumpApacheLo ...

  4. ERP系统开发平台 (C#语言,支持多数据库)

    C/S系统开发框架-企业版 V4.0 (Enterprise Edition) 简介: http://www.csframework.com/cs-framework-4.0.htm 适用软件:适合开 ...

  5. 精通 Oracle+Python,第 4 部分:事务和大型对象

    通过 Python 管理数据事务.处理大型对象 2010 年 3 月发布 事务包含一组 SQL 语句,这组 SQL 语句构成数据库中的一个逻辑操作,如转帐或信用卡支付操作.将 SQL 语句聚合到一个逻 ...

  6. 既然HTTP1.1协议里每个连接默认都是持久连接,那么为何当今所有报文都在使用Connetion:Keep-Alive

    说白了,如果你发起时有,那么服务器支持,回应时也会有,不支持,也就没有了.所以一般客户端都会默认带着发,服务端返回不返回就是服务端的事了. 1. 支不支持长连接,关键在于服务端是否支持. 如果服务端不 ...

  7. [BZOJ 1336] [Balkan2002] Alien最小圆覆盖 【随机增量法】

    题目链接:BZOJ - 1336 题目分析 最小圆覆盖有一个算法叫做随机增量法,看起来复杂度像是 O(n^3) ,但是可以证明其实平均是 O(n) 的,至于为什么我不知道= = 为什么是随机呢?因为算 ...

  8. Hidden Password

    zoj1729:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=729 题意:就是求字符串的最小表示,模板题. 题解:直接贴模板. ...

  9. Android 文件上传 使用AsyncHttpClient开源框架

    public void upload(View view) { AsyncHttpClient client = new AsyncHttpClient(); RequestParams reques ...

  10. C++ Virtual详解(注意函数被隐藏的问题)

    Virtual是C++ OO机制中很重要的一个关键字.只要是学过C++的人都知道在类Base中加了Virtual关键字的函数就是虚拟函数(例如函数print),于是在Base的派生类Derived中就 ...