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; # ...
随机推荐
- Ubuntu 18.04 安装java8
step1: 添加ppa sudo add-apt-repository ppa:webupd8team/java sudo apt-get update step2: 安装oracle-java-i ...
- ECMASCript 2019可能会有哪些特性?
最近这些年,ECMASCript标准发展节奏非常稳定,每年都会发布新的特性.那么,ECMASCript 2019可能会有哪些特性呢? ECMASCript语法提案的批准流程 JavaScript的标准 ...
- 后端开发者的Vue学习之路(五)
目录 上节内容回顾 使用第三方组件库 如何发起请求 请求错误处理 请求带参 以get的方式带参: 以post的方式带参: 封装处理 请求的配置 axios实例 实现调用自定义函数来发起请求 抽取axi ...
- 【代码笔记】Web-JavaScript-JavaScript void
一,效果图. 二,代码. <!DOCTYPE html> <html> <head> <meta charset="utf-8"> ...
- EBGP在非直连网络时,需要配置ebgp的最大跳数,否则无法建立非直连的EBGP邻居
结论: 1.默认情况下,EBGP只能在物理直连的路由器之间建立邻居. 2.要想配置非直连设备间的BGP邻居,必须加配置. 组网图: 抓包: 1.默认情况下,EBGP邻居之间的BGP报文的TTL为1. ...
- android viewpage预加载和懒加载问题
1.本人理解懒加载和预加载问题某种情况下可以归结为一类问题,下面我就说一下我遇到的预加载问题和懒加载问题及解决的相应方法: - [1 ] 预加载问题 描述:我用到了三个fragment. ...
- 如何在MongoDB设计存储你的数据(JSON化)?
第一步 定义要描述的数据集 当我们决定将数据存储下来的时候,我们首先要回答的一个问题就是:“我打算存储什么样的数据?这些数据之间有什么关系?实体之间有什么关系?实体的属性之间有什么关系”. 为了说明问 ...
- ASP.NET中弹出消息框的几种常见方法
在ASP.NET网站开发中,经常需要使用到alert消息框,尤其是在提交网页的时候,往往需要在服务器端对数据进行检验,并给出提示或警告. 这里,仅介绍几种不同的实现方法. 1.众所周知的方法是采用如下 ...
- linux $参数
$# 是传给脚本的参数个数 $0 是脚本本身的名字 $1 是传递给该shell脚本的第一个参数 $2 是传递给该shell脚本的第二个参数 $@ 是传给脚本的所有参数的列表 $* 是以一个单字符串显示 ...
- 【转载】FPGA 中的latch 锁存器
以下这篇文章讲述了锁存器的一些概念和注意事项.原文标题及链接: FPGA 中的latch 锁存器 - 快乐至永远上的博客 - 与非博客 - 与网 http://www.eefocus.com/liuy ...