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. .Net语言 APP开发平台——Smobiler学习日志:基于Access数据库的Demo

    说明:该demo是基于Access数据库进行客户信息的新增.查看.编辑 新增客户信息和客户列表 Demo下载:https://github.com/comsmobiler/demo-videos  中 ...

  2. Paypal 支付功能的 C# .NET / JS 实现

    说明 最近用到了 Paypal 支付功能,英语一般般的我也不得不硬着头皮踩一踩这样的坑.经过近乎半个月的作,终于实现了简单的支付功能,那么首先就说说使用 Paypal 必定要知道的几点(当前日期 20 ...

  3. openjduge 求简单表达式的值

    表达式求值 总时间限制:  10000ms  单个测试点时间限制:  1000ms  内存限制:  131072kB 给定一个只包含加法和乘法的算术表达式,请你编程计算表达式的值. 输入 输入仅有一行 ...

  4. Sql Server 2008日志满的解决办法

    通过sql命令 USE ZGZY; GO --由完整模式设置为简单恢复模式 ALTER DATABASE ZGZY SET RECOVERY SIMPLE WITH NO_WAIT GO --收缩日志 ...

  5. 4-4 Redis 的常用配置

    2016-12-22 15:30:43 本篇文章属于Redis 系列第四篇文章:Redis 配置文件介绍 该系列文章链接 NoSQL 数据库简介 Redis的安装及及一些杂项基础知识 Redis 的常 ...

  6. 灵活使用 console 让 js 调试更简单

    摘要: 玩转console. 原文:灵活使用 console 让 js 调试更简单 作者:前端小智 Fundebug经授权转载,版权归原作者所有. Web 开发最常用的就是 console.log , ...

  7. 35.Odoo产品分析 (四) – 工具板块(6) – 午餐管理(1)

    查看Odoo产品分析系列--目录 很多公司为都会为员工提供午餐.然而,公司内部的午餐需要适当的管理,特别是在员工或供应商数量非常重要的时候."午餐订单"模块的开发,使管理更容易,也 ...

  8. GsonFormat插件

    GsonFormat插件可以根据JSONObject格式的字符串,自动生成实体类参数. 要使用这个插件,首先要做的事下载它.方法如下: 方法一: 1.Android studio File->S ...

  9. SQL语句(理论)

    1.SQL已经成为关系数据库的标准语言 2.SQL是一个非过程化的语言,因为他一次处理一个记录 3.SQL命令比较简单,最高级的命令几天之内便可掌握. 有属下类型的命令: 查询数据. 在表中插入.修改 ...

  10. Asp.Net Core 实现服务的批量注册注入