HUNNU--湖师大--11407--It Is Cold

[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;
}


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

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
if __name__ == '__main__': # -------------Adjustable global parameters---------- n=512 # pixel number m=10 # number of time phases angle = 5 # #sample points = 360/angle on the boundary numOfAngles = int(180/angle) numOfContourPts = int(360/angle) labelID = 1 # 勾画的RS文件中第几个轮廓为GTV # path of the input data folder = 'E:\\MedData\\4DCT-202305\\' #patient = '0007921948' # 缺少时间信息 patient = '0000726380' # 病人的编号 # 呼吸曲线数据文件 vxpPath = folder+patient+'\\0000726380\\0000726380_20230420_143723.vxp' # Save the generated figures to the latex file path figPath = "D:\\HUNNU\\Research\\DMD\\4D-CT\\latex-DMD插值\\modify202305\\figure\\" # -------------Auto generated global parameters---------- # 每个dicom文件包含多少横截面 name = os.listdir(folder+patient+'\\0') cuts = [] for i in range(len(name)): if 'CT' in name[i][0:2]: cuts.append(i+1) cuts = np.array(cuts) # phase name times = np.linspace(0,90,10) # image pixel coordinate nums = np.linspace(0,n-1,n) x,y = np.meshgrid(nums,nums) # 输出dicom头文件信息 filename = folder+patient+'\\0\\CT.{}'.format(patient)+'.Image 1.dcm' print('CT dicom file information:') info = loadFileInformation(filename) # 像素之间的间距,包括列间距和行间距,单位mm SliceThickness = info['SliceThickness'] # Z轴的扫描分辨率,单位mm pixelSpace = info['pixelSpace'] # 一个像素所占的实际体积 pixelVol = float(pixelSpace[0])*float(pixelSpace[0])*float(SliceThickness) print('sliceThickness=',SliceThickness,' pixelSpace=',pixelSpace)
06-02
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值