codeforces 686A A. Free Ice Cream(水题)
2016-06-24 09:23
435 查看
题目链接:
A. Free Ice Cream
A. Free Ice Cream
//#include <bits/stdc++.h> #include <vector> #include <iostream> #include <queue> #include <cmath> #include <map> #include <cstring> #include <algorithm> #include <cstdio> using namespace std; #define Riep(n) for(int i=1;i<=n;i++) #define Riop(n) for(int i=0;i<n;i++) #define Rjep(n) for(int j=1;j<=n;j++) #define Rjop(n) for(int j=0;j<n;j++) #define mst(ss,b) memset(ss,b,sizeof(ss)); typedef long long LL; template<class T> void read(T&num) { char CH; bool F=false; for(CH=getchar();CH<'0'||CH>'9';F= CH=='-',CH=getchar()); for(num=0;CH>='0'&&CH<='9';num=num*10+CH-'0',CH=getchar()); F && (num=-num); } int stk[70], tp; template<class T> inline void print(T p) { if(!p) { puts("0"); return; } while(p) stk[++ tp] = p%10, p/=10; while(tp) putchar(stk[tp--] + '0'); putchar('\n'); } const LL mod=1e9+7; const double PI=acos(-1.0); const LL inf=1e18; const int N=(1<<18)+10; const int maxn=1005; int n,x; int main() { read(n);read(x); LL sum=x,num=0; while(n--) { char m; LL a; cin>>m>>a; if(m=='-') { if(sum>=a)sum-=a; else num++; } else sum+=a; } cout<<sum<<" "<<num<<"\n"; return 0; }
相关文章推荐
- Java字符流与字节流区别与用法分析
- 运动目标分割
- 背景建模--W4方法
- uboot移植准备四
- 背景建模--内核密度估计法
- 【LeetCode-337】House Robber III
- java垃圾收集描述
- 数据库 union 介绍
- 远程操作db2数据库表
- iOS 开发 - 播放器Demo开发记录
- 全球30篇最热门的计算机视觉和深度学习论文
- wifi定位方法
- 背景建模--基于码本背景建模
- 关于strutst2 select标签的disable属性的设置和移除
- 老生常谈 关于JavaScript的类的继承
- Codeforces Round #359 (Div. 2) B. Little Robber Girl's Zoo
- Hibernate一对一、一对多、多对多注解映射配置
- SQL 2014 AlwaysOn 搭建
- 前端面试题之Html和CSS
- (python)创建一个可以比较的自定义类