Codeforces Round #633 div2 A~C
题意:给你n个菱形方块,问能构成图示形状的有多少种
题解:自己画几个不难发现答案是n
代码:
1 #include <iostream>
2 #include <cstdio>
3 #include <cstring>
4 #include <cmath>
5 #include <algorithm>
6 #include <stack>
7 #include <queue>
8 #include <vector>
9 #include <map>
10 #include <set>
11 #include <unordered_set>
12 #include <unordered_map>
13 #define ll long long
14 #define fi first
15 #define se second
16 #define pb push_back
17 #define me memset
18 const int N = 1e6 + 10;
19 const int mod = 1e9 + 7;
20 using namespace std;
21 typedef pair<int,int> PII;
22 typedef pair<long,long> PLL;
23
24 int t;
25 ll n;
26
27 int main() {
28 ios::sync_with_stdio(false);
29 cin>>t;
30 while(t--){
31 cin>>n;
32 printf("%lld\n",n);
33
34 }
35
36
37
38 return 0;
39 }
B. Sorted Adjacent Differences
题意:给你一个长度为n的数组a,将a重新排序,使得相邻两项之间的差非递减.
题解:每两项之间的差要非递减,那么我们从后往前看,最后两项一定可以是a的最大值和最小值,然后是a的第二大和第二小.,一直往前枚举即可.
代码:
1 #include <iostream>
2 #include <cstdio>
3 #include <cstring>
4 #include <cmath>
5 #include <algorithm>
6 #include <stack>
7 #include <queue>
8 #include <vector>
9 #include <map>
10 #include <set>
11 #include <unordered_set>
12 #include <unordered_map>
13 #define ll long long
14 #define fi first
15 #define se second
16 #define pb push_back
17 #define me memset
18 const int N = 1e6 + 10;
19 const int mod = 1e9 + 7;
20 using namespace std;
21 typedef pair<int,int> PII;
22 typedef pair<long,long> PLL;
23
24 int t;
25 int n;
26 int cnt;
27 ll a[N],b[N];
28 int main() {
29 ios::sync_with_stdio(false);
30 cin>>t;
31 while(t--){
32 cin>>n;
33 cnt=0;
34 for(int i=0;i<n;++i) cin>>a[i];
35
36 sort(a,a+n);
37
38 for(int i=0;i<(n+1)/2;++i){
39 if(i==(n+1)/2-1 && n%2!=0){
40 b[cnt++]=a[i];
41 }
42 else {
43 b[cnt++] = a[i];
44 b[cnt++] = a[n - i - 1];
45 }
46 }
47 for(int i=cnt-1;i>=0;--i){
48 printf("%lld ",b[i]);
49 }
50 puts("");
51
52 }
53
54
55
56 return 0;
57 }
题意:给你一个长度为n的数组a,从第1秒开始,你可以在第i秒的时候对a的任意项加上2^(i-1),问最少在多少秒的时候使得a的所有元素非递减.
题解:最优解一定要满足差值最大的那个逆序对,所以我们在输入的时候维护一个逆序对的最大差值ma,然后只要让某一秒时的sum>ma就行了.
代码:
1 #include <iostream>
2 #include <cstdio>
3 #include <cstring>
4 #include <cmath>
5 #include <algorithm>
6 #include <stack>
7 #include <queue>
8 #include <vector>
9 #include <map>
10 #include <set>
11 #include <unordered_set>
12 #include <unordered_map>
13 #define ll long long
14 #define fi first
15 #define se second
16 #define pb push_back
17 #define me memset
18 const int N = 1e6 + 10;
19 const int mod = 1e9 + 7;
20 using namespace std;
21 typedef pair<int,int> PII;
22 typedef pair<long,long> PLL;
23
24 int t;
25 int n;
26 ll a[N];
27 ll res=-1e9-10,ma=-1e9-10;
28 int main() {
29 ios::sync_with_stdio(false);
30 cin>>t;
31 while(t--){
32 cin>>n;
33 res=-1e9-10,ma=-1e9-10;
34 for(int i=0;i<n;++i){
35 cin>>a[i];
36 if(a[i]<res) ma=max(ma,res-a[i]);
37 res=max(res,a[i]);
38 }
39 ll s=1,sum=0,cnt=0;
40 while(sum<ma){
41 sum+=s;
42 s*=2;
43 cnt++;
44 }
45 printf("%lld\n",cnt);
46 }
47
48 return 0;
49 }
Codeforces Round #633 div2 A~C的更多相关文章
- Codeforces Round #539 div2
Codeforces Round #539 div2 abstract I 离散化三连 sort(pos.begin(), pos.end()); pos.erase(unique(pos.begin ...
- 【前行】◇第3站◇ Codeforces Round #512 Div2
[第3站]Codeforces Round #512 Div2 第三题莫名卡半天……一堆细节没处理,改一个发现还有一个……然后就炸了,罚了一啪啦时间 Rating又掉了……但是没什么,比上一次好多了: ...
- Codeforces Round#320 Div2 解题报告
Codeforces Round#320 Div2 先做个标题党,骗骗访问量,结束后再来写咯. codeforces 579A Raising Bacteria codeforces 579B Fin ...
- Codeforces Round #564(div2)
Codeforces Round #564(div2) 本来以为是送分场,结果成了送命场. 菜是原罪 A SB题,上来读不懂题就交WA了一发,代码就不粘了 B 简单构造 很明显,\(n*n\)的矩阵可 ...
- Codeforces Round #633 (Div. 2)
Codeforces Round #633(Div.2) \(A.Filling\ Diamonds\) 答案就是构成的六边形数量+1 //#pragma GCC optimize("O3& ...
- Codeforces Round #361 div2
ProblemA(Codeforces Round 689A): 题意: 给一个手势, 问这个手势是否是唯一. 思路: 暴力, 模拟将这个手势上下左右移动一次看是否还在键盘上即可. 代码: #incl ...
- Codeforces Round #626 Div2 D,E
比赛链接: Codeforces Round #626 (Div. 2, based on Moscow Open Olympiad in Informatics) D.Present 题意: 给定大 ...
- CodeForces Round 192 Div2
This is the first time I took part in Codeforces Competition.The only felt is that my IQ was contemp ...
- Codeforces Round #359 div2
Problem_A(CodeForces 686A): 题意: \[ 有n个输入, +\space d_i代表冰淇淋数目增加d_i个, -\space d_i表示某个孩纸需要d_i个, 如果你现在手里 ...
随机推荐
- Java多线程-锁的区别与使用
目录 锁类型 可中断锁 公平锁/非公平锁 可重入锁 独享锁/共享锁 互斥锁/读写锁 乐观锁/悲观锁 分段锁 偏向锁/轻量级锁/重量级锁 自旋锁 Synchronized与Static Synchron ...
- 【Docker】/usr/bin/docker-current: Cannot connect to the Docker daemon at unix
------------------------------------------------------------------------------------------------- | ...
- Puzzle (II) UVA - 519
题目链接: https://vjudge.net/problem/UVA-519 思路: 剪枝+回溯 这个题巧妙的是他按照表格的位置开始搜索,也就是说表格是定的,他不断用已有的图片从(0,0)开始拼到 ...
- PAT Advanced 1004 Counting Leaves
题目与翻译 1004 Counting Leaves 数树叶 (30分) A family hierarchy is usually presented by a pedigree tree. You ...
- Django--虛擬環境Virtualenv的安裝使用
Django--虛擬環境Virtualenv的安裝使用 本次隨筆只要記錄在windows下安裝virtualenvwrapper,以及簡單的使用命令. virtualenvwrapper的安裝 ...
- selenium八大元素定位方法
1.ID定位 可以根据元素的id来定位属性,id是当前整个HTML页面中唯一的,所以可以通过id属性来唯一定位一个元素,是首选的元素定位方式.(动态ID不做考虑) # 导入webdriver和By f ...
- 浅析Linux进程空间布局
一.进程空间分布概述 对于一个进程,其空间分布如下图所示: 1.参数说明 程序段(Text):程序代码在内存中的映射,存放函数体的二进制代码. 初始化过的数据(Data):在程序运行初已经对变量进行初 ...
- 。SLI,Service Level Indicator,服务等级指标,其实就是我们选择哪些指标来衡量我们的稳定性。而 SLO,Service Level Objective,服务等级目标,指的就是我们设定的稳定性目标,比如“几个 9”这样的目标。
.SLI,Service Level Indicator,服务等级指标,其实就是我们选择哪些指标来衡量我们的稳定性.而 SLO,Service Level Objective,服务等级目标,指的就是我 ...
- 在这个示例中,使用 watch 选项允许我们执行异步操作 (访问一个 API),限制我们执行该操作的频率,并在我们得到最终结果前,设置中间状态。这些都是计算属性无法做到的。
在这个示例中,使用 watch 选项允许我们执行异步操作 (访问一个 API),限制我们执行该操作的频率,并在我们得到最终结果前,设置中间状态.这些都是计算属性无法做到的.
- Lambda架构正是这样一种用来处理不能够直接实时计算问题的通用架构
https://mp.weixin.qq.com/s/BGHOw12iCASJy1pgkYZi3w 当数据处理做不到实时,应该怎么办?