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. mac终端调用编辑器打开文件

    1.调用atom编辑器,前提是编辑器打开, cd+filename 2 .VScode里面: 调用终端:ctrl + `(esc健下面那个) 安装:shift + command+ p 安装如下插件 ...

  2. C#列表页面后台代码

    using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI ...

  3. C# 如何获取Url的host以及是否是http

    参考资料:https://sites.google.com/site/netcorenote/asp-net-core/get-scheme-url-host Example there's an g ...

  4. Java AQS 概述

    AQS 概述 AQS(队列同步器,AbstractQueuedSynchronizer),是用来构建锁或其他同步组件的核心基础框架(比如 ReentrantLock.ReentrantReadWrit ...

  5. jQuery 嵌套 event 会触发多次的原因

    Html代码如下: <div id="cover"> <input type="button" id="inside" v ...

  6. 解决: 移动端经mouseover显示出的弹层中链接点击问题

    通常我们会遇到这样的需求,导航菜单在鼠标划过的时候显示自定义弹层,在弹层中有一些链接需要点击后跳转或者其他一些事件.比如: $(".menu li").on("mouse ...

  7. activeMQ类别和流程

    Point-to-Point (点对点)消息模式开发流程 :        1.生产者(producer)开发流程: 1.1 创建Connection: 根据url,user和password创建一个 ...

  8. iOS UITextField 响应键盘的return 事件

    UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(, , , )] textField.returnKeyT ...

  9. js 学习之路4:js运行/输出中文乱码问题解决

    网上找了一个简单的例子,编写出来很简单,但是乱码的问题稍微困扰了一下. 题目: 1. 大马驮2石粮食,中马驮1石粮食,两头小马驮一石粮食,要用100匹马,驮100石粮食,该如何调配? js解决代码: ...

  10. python3 OrderedDict类(有序字典)

    创建有序字典 import collections dic = collections.OrderedDict() dic['k1'] = 'v1' dic['k2'] = 'v2' dic['k3' ...