Codeforces Good Bye 2013
2015-02-02 22:50
281 查看
做Good Bye 2014那个晚上做着练习的。
379A - New Year Candles:
这居然是协会十一时出的一道题,简单题不多说了。
379B - New Year Present:
输入钱包个数,和每个钱包需要放的硬币个数,指挥机器人放硬币,不能在同一个地方连续放,输出操作方法。
因为没有说是最少步数,只是限制在10^6以下,所以从左往右放直到放满所有。
379C - New Year Ratings Change:
输入人数和每个人当前的rating,求变动后rating,要求不能有人rating相同。
一开始超时了好多次,Ac的这次764ms,也不是很理想。
排序以后为每个人的rating赋值,赋他当前的rating或者之前rating的最大值+1。
379A - New Year Candles:
这居然是协会十一时出的一道题,简单题不多说了。
#include<cstdio> int main(){ int a,b,left,cnt; while(scanf("%d%d",&a,&b)!=EOF){ cnt=0; for(left=a;left>=b;left-=b-1){ cnt+=b; } cnt+=left; printf("%d\n",cnt); } }
379B - New Year Present:
输入钱包个数,和每个钱包需要放的硬币个数,指挥机器人放硬币,不能在同一个地方连续放,输出操作方法。
因为没有说是最少步数,只是限制在10^6以下,所以从左往右放直到放满所有。
#include<cstdio> #include<cstring> const int maxn=310; int a[maxn],cur,flag,sum,n; void put_coin(){ if(a[cur]&&!flag){ flag=1,--a[cur],--sum; putchar('P'); } else if(a[cur]){ if(cur!=n-1){ putchar('R'); if(a[cur+1]){ --a[cur+1],--sum; putchar('P'); } --a[cur],--sum; putchar('L'); putchar('P'); } else{ putchar('L'); putchar('R'); putchar('P'); --a[cur],--sum; } } else if(cur!=n-1){ flag=0,++cur; putchar('R'); } else{ flag=0,--cur; putchar('L'); } if(sum) put_coin(); } int main(){ while(scanf("%d",&n)!=EOF){ cur=flag=sum=0; memset(a,0,sizeof(a)); for(int i=0;i<n;++i){ scanf("%d",&a[i]); sum+=a[i]; } put_coin(); putchar('\n'); } return 0; }
379C - New Year Ratings Change:
输入人数和每个人当前的rating,求变动后rating,要求不能有人rating相同。
一开始超时了好多次,Ac的这次764ms,也不是很理想。
排序以后为每个人的rating赋值,赋他当前的rating或者之前rating的最大值+1。
#include<cstdio> #include<algorithm> #include<cstring> using namespace std; const int maxn=300010; struct rating{ int res,num,rate; rating(int res=0,int num=0):res(res),num(num),rate(0){} }; rating a[maxn]; bool cmp1(rating a,rating b){ return a.res<b.res; } bool cmp2(rating a,rating b){ return a.num<b.num; } int main(){ int n; while(scanf("%d",&n)!=EOF){ memset(a,0,sizeof(a)); for(int i=0;i<n;i++){ int k; scanf("%d",&k); a[i]=rating(k,i); } sort(a,a+n,cmp1); int last=0; for(int i=0;i<n;i++){ if(last>=a[i].res){ a[i].rate=last; ++last; } else{ a[i].rate=a[i].res; last=a[i].res+1; } } sort(a,a+n,cmp2); for(int i=0;i<n;i++){ if(i) printf(" "); printf("%d",a[i].rate); } printf("\n"); } return 0; }
相关文章推荐
- Codeforces Good Bye 2013 ABCDE
- CodeForces Good Bye 2013
- Codeforces Good Bye 2013
- codeforces GOOD BYE 2013
- codeforces Good Bye 2013 379D New Year Letter
- Codeforces Good Bye 2017 C - New Year and Curling
- Codeforces Good Bye 2016部分题解
- Codeforces Good Bye 2017 908F - New Year and Rainbow Roads 贪心+模拟
- Good Bye 2013!
- Codeforces 611C. New Year and Domino (Good Bye 2015 C题)
- Good Bye 2013---B. New Year Present
- Codeforces Good Bye 2017: F. New Year and Rainbow Roads(模拟)
- codeforces Good Bye 2017
- Codeforces Good Bye 2014 A.B.C.D.
- codeforces Good Bye 2016-B New Year and North Pole
- Good Bye 2013
- Codeforces Good Bye 2015 C. New Year and Domino 前缀和
- Codeforces Good Bye 2015 B. New Year and Old Property (DFS)
- Codeforces Good Bye 2015
- 【Codeforces Good Bye 2015】D. New Year and Ancient Prophecy