CodeForces Round #544 Div.3
A. Middle of the Contest
代码:
#include <bits/stdc++.h>
using namespace std; int h1, m1, h2, m2;
int tim1 = , tim2 = ; int main() {
scanf("%d:%d", &h1, &m1);
scanf("%d:%d", &h2, &m2); tim1 = h1 * + m1;
tim2 = h2 * + m2; tim2 -= tim1;
tim2 /= ;
tim1 += tim2; int h3 = tim1 / , m3 = tim1 % ;
printf("%02d:%02d\n", h3, m3); return ;
}
B. Preparation for International Women's Day
代码:
#include <bits/stdc++.h>
using namespace std; const int maxn = 2e5 + ;
int N, K;
int a[maxn], vis[]; int main() {
scanf("%d%d", &N, &K);
int ans = , cnt = ;
for(int i = ; i <= N; i ++) {
int x;
scanf("%d", &x);
if(x % K == ) ans ++;
else vis[x % K] ++;
} ans /= ; for(int i = ; i <= K / ; i ++) {
if(i * != K) ans += min(vis[i], vis[K - i]);
else ans += (vis[i] / );
} printf("%d\n", ans * );
return ;
}
C. Balanced Team
代码:
#include <bits/stdc++.h>
using namespace std; const int maxn = 2e5 + ;
int N;
int a[maxn]; int main() {
scanf("%d", &N);
for(int i = ; i < N; i ++)
scanf("%d", &a[i]); sort(a, a + N); int maxx = ;
int l = , r = ;
while(l <= r && r < N && l < N) {
while(a[r] - a[l] <= && r < N) r ++;
maxx = max(maxx, r - l);
l ++;
} printf("%d\n", maxx); return ;
}
D. Zero Quantity Maximization

不敢相信现在会因为数组开小 wa 了四发 2e5 被我开成 1e5 我都不知道我这四次在改什么 是猪吧
代码:
#include <bits/stdc++.h>
using namespace std; const int maxn = 2e5 + ;
int N;
int a[maxn], b[maxn];
map<pair<int, int> , int> mp; int gcd(int a, int b) {
return b == ? a : gcd(b, a % b);
} int main() {
scanf("%d", &N);
for(int i = ; i < N; i ++)
scanf("%d", &a[i]); int cnt = , maxx = ;
mp.clear();
for(int i = ; i < N; i ++) {
scanf("%d", &b[i]);
if(a[i] == ) {
if(b[i] == ) cnt ++;
continue;
}
int t = gcd(a[i], b[i]);
pair<int, int> p;
p.first = a[i] / t, p.second = b[i] / t;
if(p.first < ) p.first *= -, p.second *= -;
mp[p] ++;
maxx = max(maxx, mp[p]);
} printf("%d\n", maxx + cnt); return ;
}
E. K Balanced Teams
代码:
#include <bits/stdc++.h>
using namespace std; const int maxn = ;
int N, K;
int a[maxn], dp[maxn][maxn]; int main() {
scanf("%d%d", &N, &K);
for(int i = ; i <= N; i ++)
scanf("%d", &a[i]); sort(a + , a + N + );
memset(dp, , sizeof(dp));
int pos = ;
for(int i = ; i <= N; i ++) {
while(a[i] - a[pos] > && pos <= N) pos ++;
for(int j = ; j <= min(K, i); j ++) {
dp[i][j] = max(dp[i - ][j], dp[pos - ][j - ] + i - pos + );
}
} int ans = ;
for(int i = ; i <= K; i ++) {
ans = max(ans, dp[N][i]);
} printf("%d\n", ans); return ;
}
F1. Spanning Tree with Maximum Degree
代码:
#include <bits/stdc++.h>
using namespace std; const int maxn = 2e5 + ;
int N, M;
vector<int> v[maxn];
int vis[maxn], son[maxn];
int maxx = , temp;
vector<int> u;
vector<vector<int> > ans; void bfs(int st) {
vis[st] = ;
queue<int> q;
while(!q.empty()) q.pop();
q.push(st);
while(!q.empty()) {
int tp = q.front();
q.pop();
for(int i = ; i < v[tp].size(); i ++) {
if(!vis[v[tp][i]]) {
vis[v[tp][i]] = ;
printf("%d %d\n", tp, v[tp][i]);
q.push(v[tp][i]);
}
}
}
} int main() {
scanf("%d%d", &N, &M);
while(M --) {
int a, b;
scanf("%d%d", &a, &b);
v[a].push_back(b);
v[b].push_back(a);
son[a] ++, son[b] ++;
} for(int i = ; i <= N; i ++) {
if(son[i] > maxx) {
maxx = son[i];
temp = i;
}
} bfs(temp);
return ;
}
F2. Spanning Tree with One Fixed Degree

今天也是被奶茶治愈的一天
CodeForces Round #544 Div.3的更多相关文章
- Codeforces Round #544 (Div. 3) 题解
Codeforces Round #544 (Div. 3) D. Zero Quantity Maximization 题目链接:https://codeforces.com/contest/113 ...
- Codeforces Round #544 (Div. 3) dp + 双指针
https://codeforces.com/contest/1133/problem/E 题意 给你n个数(n<=5000),你需要对其挑选并进行分组,总组数不能超过k(k<=5000) ...
- Codeforces Round #544 (Div. 3) D. Zero Quantity Maximization
链接:https://codeforces.com/contest/1133/problem/D 题意: 给两个数组a,b. 同时ci = ai * d + bi. 找到一个d使c数组中的0最多. 求 ...
- Codeforces Round #544 (Div. 3) C. Balanced Team
链接:https://codeforces.com/contest/1133/problem/C 题意: 给n个数, 在这n个数中选最多n个数,来组成一个队伍. 保证这n个数的最大最小差值不大于5. ...
- Codeforces Round #544 (Div. 3) B.Preparation for International Women's Day
链接:https://codeforces.com/contest/1133/problem/B 题意: 给n个数,和一个k,在n个数中选几对数,保证没对数相加可以整除k. 求最大能选几个数. 思路: ...
- Codeforces Round #544 (Div. 3) A.Middle of the Contest
链接:https://codeforces.com/contest/1133/problem/A 题意: 给两个时间点,求中间时间点. 思路: 数学 代码: #include <bits/std ...
- Codeforces Round #544 (Div. 3) Editorial C. Balanced Team
http://codeforces.com/contest/1133/problem/Ctime limit per test 2 secondsmemory limit per test 256 m ...
- Codeforces Round #544 (Div. 3) D F1 F2
题目链接:D. Zero Quantity Maximization #include <bits/stdc++.h> using namespace std; #define maxn ...
- Codeforces Round #544 (Div. 3)解题报告
A.Middle of the Contest 考虑把输入的时间单位化成分钟,相加除以2就好了 #include<bits/stdc++.h> using namespace std; # ...
随机推荐
- c#计算机视觉库openCVSharp
作为研究计算机视觉的一员,大家肯定对Intel大名鼎鼎的openCV系列计算机视觉库耳熟能详,对于很多人来说openCV甚至已经成为其项目研究不可缺少的一部分.但是,由于项目兼容性的要求.openCV ...
- Android破解——支付宝内购破解方法总结
支付宝破解三种方式: 想学一下支付宝内购的相关知识,但是搜索了论坛,发现但是没有相关的帖子,于是便是打算自己来写一篇总结 一.9000的十六进制代码修改 搜索9000的十六进制,也就是搜索0x2328 ...
- 【Mybatis】使用Mybatis-Generator自动生成entity、dao、mapping
使用过mybatis的应该都有用过Mybatis-Generator,本文主要介绍使用Mybatis-Generator来自动生成entity.dao.mapping文件. Mybatis-Gener ...
- IIS中虚拟目录不继承主站点web.config设置的办法(转载)
ASP.NET提供了强大的Web.config来配置网站,一般来说一个网站只有一个根目录下的Web.config文件,有时候我们希望子目录有着不同的权限或者参数设置,则可以在相应子目录增加一个Web. ...
- 在虚拟机中搭建qduoj(二)——安装OJ
在上一章中,我们已经做好了准备工作,现在,正式开始搭建OJ. 可以先看看官方文档: https://github.com/QingdaoU/OnlineJudgeDeploy/tree/2.0 运行p ...
- 你真的了解PeopleSoft中的function和method方法嘛
谈下function和method在内嵌与外部传参的区别 1.内嵌函数(Internal Functions) 看下现在输出&x的话会返回什么值? 2.内嵌函数(Internal Functi ...
- clCreateBuffer和clCreateBuufer + clEnqueueWriteBuffer
有两种方式实现从主机到CL设备的数据传递, 第一种: cl_mem input = clCreateBuffer(context,CL_MEM_READ_ONLY,sizeof(float) * DA ...
- Centos 7 安装 ifconfig 管理命令
1. 安装的需求背景 我们知道ifconfig 命令可以用于查看.配置.启用或禁用指定网络接口,如配置网卡的IP地址.掩码.广播地址.网关等,功能不可谓不丰富. 此命令的功能和windows系统的ip ...
- 20180831-Linux环境下Python 3.6.6 的安装说明
20180831-Linux环境下Python 3.6.6 的安装说明 摘要:Python3 安装部署,普通用户,编译安装 Author: andy_yhm@yeah.net Date: 201808 ...
- Asp.Net Core 下 Newtonsoft.Json 转换字符串 null 替换成string.Empty
public class NullToEmptyStringResolver : DefaultContractResolver { /// <summary> /// 创建属性 /// ...