CF#317div2

A Arrays

水题,数组A中是否存在k本书使任意一本书,严格小于数组B中的m本书中的每本书,做一次排序,使A[k-1]<B中第M大的书。存在输出“Yes”,反之“No”

 1 #include<stdio.h>
 2 #include<math.h>
 3 #include<string.h>
 4 #include<stdlib.h>
 5 #include<ctype.h>
 6 #include <map>
 7 #include <set>
 8 #include <cmath>
 9 #include <deque>
10 #include <queue>
11 #include <stack>
12 #include <cstdio>
13 #include <cctype>
14 #include <string>
15 #include <vector>
16 #include <cstdlib>
17 #include <cstring>
18 #include <iostream>
19 #include <algorithm>
20 #define LL long long
21 #define INF 0x7fffffff
22 using namespace std;
23
24
25 int main()
26 {
27     //printf("%10s","hhhh");
28     //printf("%*s",10,"hhhhhh");
29     int N1,N2,k,m;
30     int a[100005],b[100005];
31     int t1=N1-1;
32     int t2=N2-m;
33     cin>>N1>>N2>>k>>m;
34     for(int i=0;i<N1;i++){
35         cin>>a[i];
36     }
37     for(int i=0;i<N2;i++){
38         cin>>b[i];
39     }
40     if(a[k-1]<b[N2-m])
41     cout<<"YES"<<endl;
42     else
43     cout<<"NO"<<endl;
44
45     return 0;
46 }

B Order Book

还是水题,但是题意太坑,里面buy和sell是买贵的,卖便宜的,此外,输出的时候,全部按照升序排列。

 1 #include<stdio.h>
 2 #include<math.h>
 3 #include<string.h>
 4 #include<stdlib.h>
 5 #include<ctype.h>
 6 #include <map>
 7 #include <set>
 8 #include <cmath>
 9 #include <deque>
10 #include <queue>
11 #include <stack>
12 #include <cstdio>
13 #include <cctype>
14 #include <string>
15 #include <vector>
16 #include <cstdlib>
17 #include <cstring>
18 #include <iostream>
19 #include <algorithm>
20 #define LL long long
21 #define INF 0x7fffffff
22 using namespace std;
23
24 #define N 1005
25 #define M 100005
26  int pb[N],ps[N],qb[M],qs[M];
27  int n,s;
28
29 int main()
30 {
31     for(int i=0;i<N;i++){
32         pb[i]=0;
33         ps[i]=0;
34     }
35     for(int i=0;i<M;i++){
36         qb[i]=0;
37         qs[i]=0;
38     }
39     cin>>n>>s;
40     char t;
41     int t1=0;
42     int t2=0;
43     int temp,x;
44     for(int i=0;i<n;i++){
45         getchar();
46         cin>>t;
47         if(t==‘B‘)
48         {
49             cin>>x>>temp;
50             if(qb[x]==0)
51             {
52                 pb[t1]=x;
53                 t1++;
54                 //cout<<t1<<" "<<t2<<"????"<<endl;
55             }
56             qb[x]+=temp;
57             //else cout<<qb[pb[t1-1]]<<endl;
58         }
59         else if(t==‘S‘){
60             cin>>x>>temp;
61             if(qs[x]==0)
62             {
63                 ps[t2]=x;
64                 t2++;
65             //    cout<<t1<<" "<<t2<<"????"<<endl;
66             }
67             qs[x]+=temp;
68             //else cout<<qs[ps[t2-1]]<<endl;
69         }
70 //        for(int i=0;i<t1;i++){
71 //            cout<<qb[pb[i]]<<endl;
72 //        }
73 //        for(int i=0;i<t2;i++){
74 //            cout<<qs[ps[i]]<<endl;
75 //        }
76     }
77     //cout<<t1<<" "<<t2<<endl;
78     sort(pb,pb+t1);
79     reverse(pb,pb+t1);
80     sort(ps,ps+t2);
81     reverse(ps,ps+t2);
82     for(int j=min(s,t2);j>0;j--){
83         cout<<"S "<<ps[t2-j]<<" "<<qs[ps[t2-j]]<<endl;
84         //cout<<i<<" "<<t2<<endl;
85     }
86     for(int i=0;i<s&&i<t1;i++){
87         cout<<"B "<<pb[i]<<" "<<qb[pb[i]]<<endl;
88         //cout<<i<<" "<<t1<<endl;
89     }
90     return 0;
91 }

时间: 2025-01-01 21:21:59

CF#317div2的相关文章

微信 {&quot;errcode&quot;:40029,&quot;errmsg&quot;:&quot;invalid code, hints: [ req_id: Cf.y.a0389s108 ]&quot;}

{"errcode":40029,"errmsg":"invalid code, hints: [ req_id: Cf.y.a0389s108 ]"} 问题:微信网页授权后,获取到 openid 了,一刷新又没了 微信网页授权获取到的 code 只能使用一次(5分钟内有效),使用一次后,马上失效. 页面授权跳转成功,根据 code 也换取到 openid 了. 此时刷新页面,并不会再次进行授权,而是直接刷新了一下上一次授权跳转后的链接,带的还是

CF with friends and user&#39;s influence considered on NYC data(updated Aug,11st)

Here is the code link: https://github.com/FassyGit/LightFM_liu/blob/master/U_F1.py I use NYC data as other experimens. The split of the training data was seperated by the timeline, and I have normalised the interaction matrix by replacing the checkin

CF 750

今天CF打的块残废了     就是一废物 A 在24点之前到 直接模拟即可 #include<stdio.h> #include<algorithm> #include<cstring> #include<string> #include<cmath> using namespace std; #define LL long long #define MAXN 1010 #define inf 1000000000.0 int main() {

CF #394 (2) 5/6

Codeforces Round #394 (Div. 2) 总结:有毒的一场比赛.做了三题,结果A被叉,B.C挂综测,还hack失败一发,第一次在CF体会到了-50分的感觉..不知道是不是人品好,比赛时room炸了,然后,unrated.. A  水题,判一下0 0,然后abs(a-b)<=1 B  水题,组个间距比较一下,但一个数的时候要判一下 C  直接暴力上的题 D  也是xjb暴力 题意:给出n,l,r, a[], p[],另有两个数组b[], c[],ci=bi-ai.l<=ai,

一场CF的台前幕后(上)——转

前奏 大约4月份的时候,业界毒瘤pyx噔噔噔跑过来说:“酷爱!我YY了一道题!准备当CF的C” 我当时就被吓傻了."Yet another Chinese round?" “区间取模,区间求和” 感觉这题还不错?不过pyx嫌水了…… 好办!当时我刚刚出完动态仙人掌不久,于是一拍脑袋说:把这个问题出到仙人掌上去! 当然被pyx鄙视了…… 后来一直就没啥动静,直到5月底的CTSC. 试机的时候pyx给我看了套他出的神题……里面有一道题……我不小心读成了下面这个样子: “给定n个m维的模2意

[2016-03-22][CF][69A][Young Physicist]

时间:2016-03-22 19:41:34 星期二 题目编号:[2016-03-22][CF][69A][Young Physicist] 题目大意:判断向量和是否为0 分析:对应坐标相加 遇到的问题:不能用x+y+z来判断是否都为0,除非输入都是正数 #include <cstdio> using namespace std; int main(){ int a,b,c,x,y,z,n; x = y = z = 0; scanf("%d",&n); for(in

ARC下OC对象和CF对象之间的桥接(bridge)

在开发iOS应用程序时我们有时会用到Core Foundation对象简称CF,例如Core Graphics.Core Text,并且我们可能需要将CF对象和OC对象进行互相转化,我们知道,ARC环境下编译器不会自动管理CF对象的内存,所以当我们创建了一个CF对象以后就需要我们使用CFRelease将其手动释放,那么CF和OC相互转化的时候该如何管理内存呢?答案就是我们在需要时可以使用__bridge,__bridge_transfer,__bridge_retained,具体介绍和用法如下

【CF 520D】Cubes

[CF 520D]Cubes 怎么说呢--英语阅读题+超级大模拟-- 最重要的是知道怎么出来的数据...题意好懂 xy坐标内给出几个单位正方形 以正方形左下点坐标给出 y=0为地面 正方形下面或者左右下方至少存在一个正方形他才能稳定.. 正方形按0~m-1标号 每次只能取出不影响整体结构的正方形 甲乙玩一个游戏 交替取正方形 每取下一个按从左到右的顺序排好 得到一个大数 重点来了! 取出的数是m进制 转换为十进制是最终结果 甲希望结果最大 乙希望结果最小 问结果为多少 甲先取 题意明白了模拟就行

cf 148D Bag of mice

The dragon 选一只老鼠,然后会跑掉一只 the princess选一只老鼠,不会跑出另外的老鼠 求the princess赢的概率 1 #include<iostream> 2 #include<string> 3 #include<cstdio> 4 #include<vector> 5 #include<queue> 6 #include<stack> 7 #include<algorithm> 8 #inc