Codeforces Round #413 B. T-shirt buying
来源:互联网 发布:mac u盘 没有退出选项 编辑:程序博客网 时间:2024/06/01 10:37
传送门
题目大意是:p为衣服价值,a为衣服前面的颜色,b为衣服后面的颜色,m是买的人有多少个。c是这些人喜欢的颜色。
如果这些人能在剩下的衣服中找到自己想要的颜色的衣服就买下来 当然是买当前最便宜的嘛。
#include <bits/stdc++.h>//#include <ext/pb_ds/tree_policy.hpp>//#include <ext/pb_ds/assoc_container.hpp>//using namespace __gnu_pbds;using namespace std;#define pi acos(-1)#define endl '\n'#define me(x) memset(x,0,sizeof(x));#define foreach(it,a) for(__typeof((a).begin()) it=(a).begin();it!=(a).end();it++)#define close() ios::sync_with_stdio(0);#define rand() srand(time(0));typedef long long LL;typedef pair<int, int> pii;const int INF=0x3f3f3f3f;const LL LINF=0x3f3f3f3f3f3f3f3fLL;//const int dx[]={-1,0,1,0,-1,-1,1,1};//const int dy[]={0,1,0,-1,1,-1,1,-1};const int maxn=1e3+5;const int maxx=2e5+100;const double EPS=1e-9;const int MOD=1000000007;#define mod(x) ((x)%MOD);template<class T>inline T min(T a,T b,T c) { return min(min(a,b),c);}template<class T>inline T max(T a,T b,T c) { return max(max(a,b),c);}template<class T>inline T min(T a,T b,T c,T d) { return min(min(a,b),min(c,d));}template<class T>inline T max(T a,T b,T c,T d) { return max(max(a,b),max(c,d));}//typedef tree<pt,null_type,less< pt >,rb_tree_tag,tree_order_statistics_node_update> rbtree;/*lch[root] = build(L1,p-1,L2+1,L2+cnt); rch[root] = build(p+1,R1,L2+cnt+1,R2);中前*//*lch[root] = build(L1,p-1,L2,L2+cnt-1); rch[root] = build(p+1,R1,L2+cnt,R2-1);中后*/long long gcd(long long a , long long b){if(b==0) return a;a%=b;return gcd(b,a);}inline int Scan(){ int res=0,ch,flag=0; if((ch=getchar())=='-')flag=1; else if(ch>='0' && ch<='9')res=ch-'0'; while((ch=getchar())>='0'&&ch<='9')res=res*10+ch-'0'; return flag ? -res : res;}struct node{ int p,a,b;}Q[maxx];map<int,int >vis;stack<int >s1,s2,s3;bool cmp(node A,node B){ if(A.p!=B.p) return A.p>B.p;//价格排序 因为用到stack 所以最大值放最前面}int c[maxx];int main(){ int n,m,x; scanf("%d",&n); for(int i=1;i<=n;i++) Q[i].p=Scan(); for(int i=1;i<=n;i++) Q[i].a=Scan(); for(int i=1;i<=n;i++) Q[i].b=Scan(); sort(Q+1,Q+n+1,cmp); scanf("%d",&m); for(int i=1;i<=n;i++) { vis[Q[i].p]=0; if(Q[i].a==1||Q[i].b==1) s1.push(Q[i].p);//分三个stack分别在1-2-3颜色里找衣服的价格 if(Q[i].a==2||Q[i].b==2) s2.push(Q[i].p); if(Q[i].a==3||Q[i].b==3) s3.push(Q[i].p); } for(int i=1;i<=m;i++) { int flag=0; scanf("%d",&x); if(x==1) { while(!s1.empty()) { int h=s1.top(); s1.pop(); if(vis[h]==0) { printf("%d ",h); vis[h]=1; flag=1; break; } } if(!flag) printf("-1 "); } if(x==2) { while(!s2.empty()) { int h=s2.top(); s2.pop(); if(vis[h]==0) { printf("%d ",h); vis[h]=1; flag=1; break; } } if(!flag) printf("-1 "); } if(x==3) { while(!s3.empty()) { int h=s3.top(); s3.pop(); if(vis[h]==0) { printf("%d ",h); vis[h]=1; flag=1; break; } } if(!flag) printf("-1 "); } }}
0 0
- Codeforces Round #413 B. T-shirt buying
- Codeforces Round #413 B. T-shirt buying
- codeforces round #412 B. T-shirt buying
- Codeforces Round #413 Div. 1 + Div. 2 B. T-shirt buying
- Codeforces Round #413 (Div.1 + Div. 2) B. T-shirt buying
- codeforces Round #413 Div. 1 + Div. 2 B T-shirt buying
- Playrix Codescapes Cup (Codeforces Round #413, rated, Div. 1 + Div. 2) B. T-shirt buying
- CodeForces 799B (B) T-shirt buying
- codeforces #413 B T-shirt buying(set快速查找)
- Codeforces 799B T-shirt buying 题解
- codeforcesPlayrix Codescapes Cup (Codeforces Round #413, rated, Div. 1 + Div. 2)B题B. T-shirt buying
- Codeforces Round #412 B. T-Shirt Hunt
- B. T-shirt buying(stl)
- Codeforces Round #412 B. T-Shirt Hunt (暴力枚举)
- T-shirt buying Codeforce 贪心
- 【Codeforces 807 B. T-Shirt Hunt】
- codeforces 412 B T-shirt Hunt
- Codeforces Round #412 (rated, Div. 2, base on VK Cup 2017 Round 3) B. T-Shirt Hunt(模拟)
- 【MoreWindows工作笔记12】WM_DRAWCLIPBOARD 监视剪切板
- cachecloud部署详细过程
- Android-进程与线程
- sklearn中的交叉验证(Cross-Validation)
- CacheCloud管理平台
- Codeforces Round #413 B. T-shirt buying
- <<Linux内核设计与实现>>读书笔记(十二)-内存管理
- web.js.创建对象
- Spring的两种事务定义方式
- 数据持久化--userDefaults
- mysql中varchar(50)最多能存多少个汉字
- opencv与tesseract
- spark-streaming kafka api(KafkaUtils.createDirectStream)使用
- javascript简单计算器