A. Restoring Three Numbers

代码:

#include <bits/stdc++.h>
using namespace std; int n[];
int a, b, c; int main() {
for(int i = ; i < ; i ++)
scanf("%d", &n[i]);
sort(n, n + );
a = n[] - n[];
b = n[] - n[];
c = n[] - n[];
printf("%d %d %d\n", a, b, c);
return ;
}

B. Make Them Equal

代码:

#include <bits/stdc++.h>
using namespace std; const int maxn = ;
int N;
int a[maxn], vis[maxn];
vector<int> ans; int main() {
scanf("%d", &N);
memset(vis, , sizeof(vis));
for(int i = ; i <= N; i ++) {
scanf("%d", &a[i]);
if(!vis[a[i]]) {
ans.push_back(a[i]);
vis[a[i]] = ;
}
} sort(ans.begin(), ans.end());
if(ans.size() == ) printf("0\n");
else if(ans.size() == ) {
if((ans[] - ans[]) % )
printf("%d\n", ans[] - ans[]);
else printf("%d\n", (ans[] - ans[]) / );
} else if(ans.size() == ) {
if(ans[] - ans[] == ans[] - ans[])
printf("%d\n", ans[] - ans[]);
else printf("-1\n");
} else printf("-1\n"); return ;
}

C. Gourmet Cat

代码:

#include <bits/stdc++.h>
using namespace std; int day[] = {, , , , , , , , , , , , , };
int a, b, c; int main() {
scanf("%d%d%d", &a, &b, &c);
int ans = ;
int t = min(a / , min(b / , c / ));
ans += t * ;
a -= (t * ), b -= (t * ), c -= (t * );
int na = a, nb = b, nc = c;
int maxx = , temp;
for(int i = ; i < ; i ++) {
int rec = ;
a = na, b = nb, c = nc;
for(int j = i; j < i + ; j ++) {
if(day[j] == ) {
if(a) a --, rec ++;
else {
maxx = max(maxx, rec); break;
}
}
else if(day[j] == ) {
if(b) b --, rec ++;
else {
maxx = max(maxx, rec);
break;
}
} else {
if(c) c --, rec ++;
else {
maxx = max(maxx, rec);
break;
}
}
}
//printf("!%d %d %d\n", i, maxx, rec);
} printf("%d\n", ans + maxx);
return ;
} /* 700000000 700000000 700000000 */

D. Walking Robot

代码:

#include <bits/stdc++.h>
using namespace std; const int maxn = 2e5 + ;
int N, b, a, na, nb;
int num[maxn]; int main() {
scanf("%d%d%d", &N, &b, &a);
for(int i = ; i <= N; i ++)
scanf("%d", &num[i]); nb = b, na = a;
int ans;
for(int i = ; i <= N; i ++) {
if(num[i] == ) {
if(nb > ) {
if(na + <= a) {
na += ;
nb -= ;
} else na -= ;
} else na -= ;
} else {
if(na > ) na -= ;
else if(nb > ) nb -= ;
}
if(na == && nb == ) {
ans = i;
break;
} //printf("%d %d\n", b, a);
}
printf("%d\n", min(ans, N));
return ;
}

CodeForces Round #552 Div.3的更多相关文章

  1. Codeforces Round #552 (Div. 3) A题

    题目网址:http://codeforces.com/contest/1154/problem/ 题目意思:就是给你四个数,这四个数是a+b,a+c,b+c,a+b+c,次序未知要反求出a,b,c,d ...

  2. Codeforces Round #552 (Div. 3) 题解

    Codeforces Round #552 (Div. 3) 题目链接 A. Restoring Three Numbers 给出 \(a+b\),\(b+c\),\(a+c\) 以及 \(a+b+c ...

  3. Codeforces Round #552 (Div. 3) F. Shovels Shop (前缀和预处理+贪心+dp)

    题目:http://codeforces.com/contest/1154/problem/F 题意:给你n个商品,然后还有m个特价活动,你买满x件就把你当前的x件中最便宜的y件价格免费,问你买k件花 ...

  4. Codeforces Round #552 (Div. 3) F题

    题目网址:http://codeforces.com/contest/1154/problem/F 题目大意:给出n,m,k,n是物体的个数,m是优惠方式的种数,k是需要购买的物体个数, 然后给出n个 ...

  5. Codeforces Round #552 (Div. 3) D题

    题目网站:http://codeforces.com/contest/1154/problem/D 题目大意:给出n个数(0或1),还有a , b, a是蓄电池容量,b是电池容量,数为1时蓄电池可以充 ...

  6. Codeforces Round #552 (Div. 3) C题

    题目网址:http://codeforces.com/contest/1154/problem/C 题目意思:小猫吃三种食物,A,B,C,一周吃食物的次序是,A,B,C,A,C,B,A,当小猫该天无食 ...

  7. Codeforces Round #552 (Div. 3) B题

    题目链接:http://codeforces.com/contest/1154/problem/B 题目大意:给出n个数,每个数都可以加上或减去这个一个数D,求对这n个数操作之后当所有数都相等时,D的 ...

  8. Codeforces Round #552 (Div. 3) EFG(链表+set,dp,枚举公因数)

    E https://codeforces.com/contest/1154/problem/E 题意 一个大小为n(1e6)的数组\(a[i]\)(n),两个人轮流选数,先找到当前数组中最大的数然后选 ...

  9. Codeforces Round #552 (Div. 3)-1154E-Two Teams-(模拟+双指针)

    http://codeforces.com/contest/1154/problem/E 解题: 举例n=10,k=1 1,2,10,4,7,6,9,8,5,3 第一次,1队先挑2,10,4这三个人 ...

  10. Codeforces Round #552 (Div. 3)-D-Walking Robot-(贪心)

    http://codeforces.com/contest/1154/problem/D 解题: 1.无光的时候优先使用太阳能电池. 2.有光的时候 (1)太阳能电池没满电,让它充,使用普通电池 (2 ...

随机推荐

  1. 【学习笔记】tensorflow基础

    目录 认识Tensorflow Tensorflow特点 下载以及安装 Tensorflow初体验 Tensorflow进阶 图 op 会话 Feed操作 张量 变量 可视化学习Tensorboard ...

  2. 从URL到看到网页的过程

    从我们输入URL并按下回车键到看到网页结果之间发生了什么?换句话说,一张网页,要经历怎样的过程,才能抵达用户面前?下面来从一些细节上面尝试一下探寻里面的秘密. 前言:键盘与硬件中断 说到输入URL,当 ...

  3. arcgis api 3.x for js 入门开发系列十二地图打印GP服务(附源码下载)

    前言 关于本篇功能实现用到的 api 涉及类看不懂的,请参照 esri 官网的 arcgis api 3.x for js:esri 官网 api,里面详细的介绍 arcgis api 3.x 各个类 ...

  4. linux下的QT打包方法

    一句话很简单,一个shell脚本搞定,不跟你嘻嘻哈哈 #!/bin/shexe="ThorIceLocker"#存放你的可执行文件的名字des="/home/ninetr ...

  5. Linux LVM学习总结——Insufficient Free Extents for a Logical Volume

    如下所示,在创建LV的时候,偶尔会遇到"Volume group "xxxx" has insufficient free space (xxxx extents): x ...

  6. C#中Skip和Take的用法

    Skip()和Take()方法都是IEnumerable<T> 接口的扩展方法,包括C#中的所有Collections类,如ArrayList,Queue,Stack等等,还有数组和字符串 ...

  7. selenium-弹窗操作(八)

    本次以笔者公告栏的 打赏 弹窗为例 对弹窗中的一些操作进行封装后,在测试中使用 作用:减少对弹窗反复操作时进行定位的麻烦,以后使用中都直接调用即可达到目的 # coding=utf-8 from se ...

  8. 20180903 - Python Pip 工具下载whl包与离线安装

    20180903 - Python Pip 工具下载whl包与离线安装 1. 我的Blog 博客园 https://www.cnblogs.com/piggybaba 个人网站 http://pigg ...

  9. FPGA驱动VGA显示静态图片

    一 .前言 本文设计思想采用明德扬至简设计法.VGA是最常见的视频显示接口,时序也较为简单.本文从利用显示屏通过VGA方式显示测试图案及静态图片着手带大家接触图像显示应用,算是为后续VGA显示摄像头采 ...

  10. Linux学习历程——Centos 7 top命令

    一.命令介绍 top 命令用于动态的监控进程活动与系统负载信息. 格式为 top [参数] 二.实例 直接运行top命令 top命令执行结果的前五行为系统整体的统计信息,代表含义如下: 第1行:系统时 ...