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. Python之celery的简介与使用

    celery的简介   celery是一个基于分布式消息传输的异步任务队列,它专注于实时处理,同时也支持任务调度.它的执行单元为任务(task),利用多线程,如Eventlet,gevent等,它们能 ...

  2. C#委托与事件学习笔记

    委托事件学习笔记 本文是学习委托和事件的笔记,水平有限,如有错漏之处,还望大神不吝赐教. 什么是委托?从字面意思来解释,就是把一个动作交给别人去执行.在实际开发中最常用的就是使一个方法可以当做一个参数 ...

  3. 对多字段进行去重 ( Linq 方式 )

    优质参考资料:http://www.cnblogs.com/A_ming/archive/2013/05/24/3097062.html

  4. JavaScript 条件语句

    if语句     有些代码块只能在一定条件下运行,通过if.if else.else代码块,可以让你的代码按条件执行. // 控制流 var foo = true; var bar = false; ...

  5. Java基础:HashMap中putAll方法的疑惑

    最近回顾了下HashMap的源码(JDK1.7),当读到putAll方法时,发现了之前写的TODO标记,当时由于时间匆忙没来得及深究,现在回顾到了就再仔细思考了下 @Override public v ...

  6. 【Mybatis】使用Mybatis-Generator自动生成entity、dao、mapping

    使用过mybatis的应该都有用过Mybatis-Generator,本文主要介绍使用Mybatis-Generator来自动生成entity.dao.mapping文件. Mybatis-Gener ...

  7. Mybatis框架基础支持层——反射工具箱之MetaClass(7)

    简介:MetaClass是Mybatis对类级别的元信息的封装和处理,通过与属性工具类的结合, 实现了对复杂表达式的解析,实现了获取指定描述信息的功能 public class MetaClass { ...

  8. 弹窗滑动,造成body跟随滑动解决办法

    今天测试的时候遇到一个移动端的bug,为什么说是移动端的呢,因为在谷歌浏览器的移动模式下,这个是不会出现的.先描述具体的情况.一个长页面(肯定是比手机长的页面,所以肯定会滑动),里面有一个按钮,点击按 ...

  9. npm run dev 启动错误:Module build failed: Error: No PostCSS Config found in:xxxxxxxxxxxxxx

    解决办法:在根目录新建postcss.config.js module.exports = { plugins: { 'autoprefixer': {browsers: 'last 5 versio ...

  10. Android 网络框架 OKHttp3

    概述 OKHttp是一个处理网络请求的框架,其优点有,支持http2,对一台机器的所有请求共享同一个socket. 内置连接池,支持连接复用,减少延迟.通过缓存避免重复的请求,请求失败时自动重试主机的 ...