UVA 11093(p246)----Just Finish it up
来源:互联网 发布:stc单片机引脚定义 编辑:程序博客网 时间:2024/06/11 20:05
#include<iostream>#include<cstdio>#include<algorithm>#include<cstring>#define debuusing namespace std;const int maxn=1e5+50;int cas=0,n;int v[maxn];int gt[maxn];int cost[maxn];void solve(){ memset(v,0,sizeof(v)); int i=0,ans=-1,pos,flag; int num=0,nw; while(i<n) { nw=0; flag=1; v[i]=1; for(int j=0; j<n; j++) { int nt=(i+j)%n; nw-=cost[nt]; nw+=gt[nt]; if(nw<0) { flag=0; pos=nt; break; } } if(flag) { ans=i; break; } i=pos+1; if(v[i]) break; } if(ans!=-1) printf("Case %d: Possible from station %d\n",++cas,ans+1); else printf("Case %d: Not possible\n",++cas);}int main(){#ifdef debug freopen("in.in","r",stdin);#endif // debug int t; scanf("%d",&t); while(t--) { scanf("%d",&n); for(int i=0; i<n; i++) scanf("%d",>[i]); for(int i=0; i<n; i++) scanf("%d",&cost[i]); solve(); } return 0;}
0 0
- UVA 11093(p246)----Just Finish it up
- UVA-11093-Just Finish It Up
- UVA - 11093 Just Finish it up 环路
- uva 11093 just finish it up
- UVa 11093 - Just Finish it up
- UVa 11093 - Just Finish it up
- Uva - 11093 - Just Finish it up
- uva 11093Just Finish it up
- UVA - 11093 - Just Finish it up
- UVa 11093 Just Finish it up 模拟
- UVa OJ 11093 - Just Finish it up
- UVA 11093Just Finish it up
- UVA 11093 Just Finish it up
- UVA-11093 Just Finish it up
- Just Finish it up UVA
- 11093 - Just Finish it up
- 11093 - Just Finish it up
- uva 11093-Just Finish it up【贪心?链表】
- Ambari,hadoop的配置,管理和监控项目入门
- 如何查看自己电脑的IP和网络运营商
- C语言高效编程
- 通过hashmap实现统计字符串数组中某个字符串出现的次数的方法
- 要求:通过创建一个货物类,添加货物基本信息,使用TreeMap进行比较输出 方法一为只比较价格;方法二为先比较价格再比较销量然后再输出
- UVA 11093(p246)----Just Finish it up
- 线程池的学习与深入研究
- Emmet的高级功能与使用技巧
- ubuntu14.04 疑难问题整理
- JSP学习笔记一之JSP的结构与生命周期
- UVA 11105(p345)----Semi-prime H-numbers
- ESP8266(二)NODEMCU——烧录固件
- StackOverflow程序员推荐:每个程序员都应读的30本书
- 使用Ambari快速部署Hadoop大数据环境