[Updating] Playrix Codescapes Cup (Codeforces Round #413, rated, Div. 1 + Div. 2) 解题报告
来源:互联网 发布:淘宝如何推广自己的店铺 编辑:程序博客网 时间:2024/05/21 11:31
Problem A - Carrot Cakes
//Author: Lixiang#include<stdio.h>struct A{ int n,t,k,d; void init(){ scanf("%d%d%d%d",&n,&t,&k,&d); } void work(){ int a=n/k; if(a*k<n)a++; a*=t; int b=d/t; if(b*t<d)b++; n-=b*k; if(n<0){ puts("NO"); return ; } b*=t; int c=n/k,ans; if(c*k<n)c++; if(c%2==1){ c=(c+1)/2; c*=t; ans=d+c; } else{ c=c/2; c*=t; ans=b+c; } if(ans<a)puts("YES"); else puts("NO"); }}sol;int main(){ sol.init(); sol.work(); return 0;}
Problem B - T-shirt buying
模拟
//Author: Lixiang#include<stdio.h>#include<map>#include<queue>using namespace std;const int maxn=200001;struct B{ map <int,bool> used; priority_queue <int,vector <int>,greater<int> > C[4]; int p[maxn],a[maxn],b[maxn]; int N,M; void init(){ scanf("%d",&N); for(int i=1;i<=N;i++) scanf("%d",p+i); for(int i=1;i<=N;i++) scanf("%d",a+i); for(int i=1;i<=N;i++) scanf("%d",b+i); for(int i=1;i<=N;i++){ C[a[i]].push(p[i]); C[b[i]].push(p[i]); used[p[i]]=1; } } void work(){ scanf("%d",&M); for(int i=1,c;i<=M;i++){ scanf("%d",&c); while(!C[c].empty()&&!used[C[c].top()])C[c].pop(); if(C[c].empty())puts("-1"); else{ printf("%d ",C[c].top()); used[C[c].top()]=0; } } }}sol;int main(){ sol.init(); sol.work(); return 0;}
Problem C - Fountains
找C+C C+D D+D三种情况中最优的
二分+贪心
//Author: Lixiang#include<stdio.h>#include<algorithm>using namespace std;const int maxn=100001;struct Fountains{ int b,p; void init(int bb,int pp){ b=bb;p=pp; } bool operator<(struct Fountains b)const{ return p<b.p; }}f[2][maxn];struct C{ int m[2][maxn]; int N,C,D,n1,n2; void init(){ char ch; scanf("%d%d%d",&N,&C,&D); for(int i=1,b,p;i<=N;i++){ scanf("%d %d %c",&b,&p,&ch); if(ch=='C')f[0][++n1].init(b,p); else f[1][++n2].init(b,p); } sort(f[0]+1,f[0]+n1+1); sort(f[1]+1,f[1]+n2+1); for(int i=1;i<=n1;i++) m[0][i]=max(m[0][i-1],f[0][i].b); for(int i=1;i<=n2;i++) m[1][i]=max(m[1][i-1],f[1][i].b); } int bs(int val,Fountains a[],int N){ int L=1,R=N,M,ans=0; while(L<=R){ M=(L+R)/2; if(a[M].p>val)R=M-1; else{ L=M+1; ans=M; } } return ans; } void work(){ int i=bs(C,f[0],n1),j=bs(D,f[1],n2); if(i==0){ int ans=0; for(;j>=2;j--){ int id=bs(D-f[1][j].p,f[1],j-1); if(id>0)ans=max(ans,m[1][id]+f[1][j].b); } printf("%d\n",ans); return ; } if(j==0){ int ans=0; for(;i>=2;i--){ int id=bs(C-f[0][i].p,f[0],i-1); if(id>0)ans=max(ans,m[0][id]+f[0][i].b); } printf("%d\n",ans); return ; } int ans=m[0][i]+m[1][j]; for(;i>=2;i--){ int id=bs(C-f[0][i].p,f[0],i-1); if(id>0)ans=max(ans,m[0][id]+f[0][i].b); } for(;j>=2;j--){ int id=bs(D-f[1][j].p,f[1],j-1); if(id>0)ans=max(ans,m[1][id]+f[1][j].b); } printf("%d\n",ans); }}sol;int main(){ sol.init(); sol.work(); return 0;}
Problem D - field expension
D题改了10发,下次再改
0 0
- [Updating] Playrix Codescapes Cup (Codeforces Round #413, rated, Div. 1 + Div. 2) 解题报告
- Playrix Codescapes Cup (Codeforces Round #413, rated, Div. 1 + Div. 2) C. Fountains(树状数组)
- Playrix Codescapes Cup (Codeforces Round #413, rated, Div. 1 + Div. 2) C Fountains 乱搞
- Playrix Codescapes Cup (Codeforces Round #413, rated, Div. 1 + Div. 2) C Fountains
- Playrix Codescapes Cup (Codeforces Round #413, rated, Div. 1 + Div. 2) A. Carrot Cakes
- Playrix Codescapes Cup (Codeforces Round #413, rated, Div. 1 + Div. 2) B. T-shirt buying
- Playrix Codescapes Cup (Codeforces Round #413, rated, Div. 1 + Div. 2) A题
- Playrix Codescapes Cup (Codeforces Round #413, rated, Div. 1 + Div. 2) B
- codeforcesPlayrix Codescapes Cup (Codeforces Round #413, rated, Div. 1 + Div. 2)A题
- CodeforcesPlayrix Codescapes Cup (Codeforces Round #413, rated, Div. 1 + Div. 2)C题C. Fountains
- codeforcesPlayrix Codescapes Cup (Codeforces Round #413, rated, Div. 1 + Div. 2)B题B. T-shirt buying
- 【解题报告】Codeforces Round #405 (rated, Div. 2, based on VK Cup 2017 Round 1)
- 【解题报告】Codeforces Round #409 (rated, Div. 2, based on VK Cup 2017 Round 2)
- [Updating] Codeforces Round #404 (Div. 2) 解题报告
- [Updating] Codeforces Round #406 (Div. 2) 解题报告
- [Updating]Codeforces Round #402 (Div. 1)解题报告
- (Codeforces Round #413, rated, Div. 1 + Div. 2)(A+B)
- 【解题报告】Codeforces Round #380 (Div. 2, Rated, Based on Technocup 2017 - Elimination Round 2)
- Application.mk浅分析
- 回溯法实现求解子集合和问题
- Charles 从入门到精通
- jsp页面更改某些链接
- echarts
- [Updating] Playrix Codescapes Cup (Codeforces Round #413, rated, Div. 1 + Div. 2) 解题报告
- SAS
- Communities Settings And Customize Community URL In Salesforce
- 字符串学习(3)
- 用编译好的源码包在linux下安装NCL
- Python数据分析之NumPy(Mooc学习笔记1,ndarray)
- 函数
- bzoj 2090: [Poi2010]Monotonicity 2 动态规划+线段树
- java list排序 -List.stream()