Gym

来源:互联网 发布:现在开淘宝店好做吗 编辑:程序博客网 时间:2024/06/05 08:40


我的AC代码:G++  405ms

#include<algorithm>     //AC#include<cstdio>using namespace std;int main(){long long x,n;char ch[3];int T;scanf("%lld",&T);while(T--){scanf("%lld",&n);long long sum=0, maxx=1e18, minn=0;for(int i=1;i<=n;i++){scanf("%lld%s",&x,ch);if(ch[0]=='+'){sum=sum+x+25;minn=sum;}elsemaxx = min(sum+x+25,maxx);}printf("%lld\n",maxx-minn);}return 0;}