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; # ...
随机推荐
- springboot新手使用guns开源框架心得
一.导航 以guns的通知管理为例 l 通知管理的请求地址是localhost:8080/notice l 程序收到这样的请求就去找地址为notice的Controller l 通知控制器收到这 ...
- alibaba fastjson 使用
// 对象转 json 字符串 User user1 = new User("Marry", 30, new Date()); String str1 = JSON.toJSONS ...
- Anaconda安装
Anaconda安装时,不用单独安装python,直接安装anaconda里面就包含有对应版本的python以及各种python包,比如常用的pandas.matplotlib.numpy等.(作为一 ...
- Android 运行报错 Unknown failure (at android.os.Binder.execTransact(Binder.java:681)) Error while Installing APKs 解决办法
今天,我用手机测试的时候出现了这个错误 我网站查找了一会资料, 在运行的时候出现提示大致意思:卸载删除已存在应用程序,是否卸载现有应用程序,点击ok就会出现如下错误 原应用程序也没有卸载,然后自己手动 ...
- JButton 按钮,JRadioJButton单选按钮,JChectBox复选框
一. [按钮JButton] //导入Java类 import javax.swing.*;import java.awt.*;import java.awt.event.ActionEvent;im ...
- ionic3 Modal组件
Modal组件主要用来弹出一些临时的框,如登录,注册的时候用 弹出页面html页面 <button ion-button small outline color="he" ...
- Linux操作系统--定时任务
最近在学习Linux操作系统.学到了关于定时任务的章节,作为一个总结写下这篇文章.在Linux中,我们可以将耗时大的任务如复制大文件,压缩.解压缩大文件等放进定时任务中(深夜执行,因为工作时间访问量大 ...
- Docker 创建 Jira Core(Jira SoftWare) 7.12.3 中文版
目录 目录 1.介绍 1.1.什么是 JIRA Core? 1.2.什么是 JIRA SoftWare 2.JIRA 的官网在哪里? 3.如何下载安装? 4.对 JIRA 进行配置 4.1.JIRA ...
- MS SQL自定义函数IsNumeric
判断字符串是否为纯数字,负数不算.如'00012','54585','1000' SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE FUN ...
- Operating system error 32(failed to retrieve text for this error. Reason: 15105)
一台数据库服务器的事务日志备份作业偶尔会出现几次备份失败的情况,具体的错误信息为: DATE/TIME: 2018/7/30 12:10:52 DESCRIPTION: BackupDiskFi ...