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的更多相关文章

  1. Codeforces Round #544 (Div. 3) 题解

    Codeforces Round #544 (Div. 3) D. Zero Quantity Maximization 题目链接:https://codeforces.com/contest/113 ...

  2. Codeforces Round #544 (Div. 3) dp + 双指针

    https://codeforces.com/contest/1133/problem/E 题意 给你n个数(n<=5000),你需要对其挑选并进行分组,总组数不能超过k(k<=5000) ...

  3. 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最多. 求 ...

  4. Codeforces Round #544 (Div. 3) C. Balanced Team

    链接:https://codeforces.com/contest/1133/problem/C 题意: 给n个数, 在这n个数中选最多n个数,来组成一个队伍. 保证这n个数的最大最小差值不大于5. ...

  5. Codeforces Round #544 (Div. 3) B.Preparation for International Women's Day

    链接:https://codeforces.com/contest/1133/problem/B 题意: 给n个数,和一个k,在n个数中选几对数,保证没对数相加可以整除k. 求最大能选几个数. 思路: ...

  6. Codeforces Round #544 (Div. 3) A.Middle of the Contest

    链接:https://codeforces.com/contest/1133/problem/A 题意: 给两个时间点,求中间时间点. 思路: 数学 代码: #include <bits/std ...

  7. 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 ...

  8. Codeforces Round #544 (Div. 3) D F1 F2

    题目链接:D. Zero Quantity Maximization #include <bits/stdc++.h> using namespace std; #define maxn ...

  9. Codeforces Round #544 (Div. 3)解题报告

    A.Middle of the Contest 考虑把输入的时间单位化成分钟,相加除以2就好了 #include<bits/stdc++.h> using namespace std; # ...

随机推荐

  1. oracle安装数据库中文乱码解决办法

    解决办法1: Linux下安装Oracle11g中文乱码 Linux下安装Oracle11g,安装界面乱码问题解决方法: 解决安装时中文是"囗囗囗囗囗囗囗囗" 1.进入刚解压的da ...

  2. .NET平台下使用Redis

    using DBI.SaaS.Web.Models.Args; using Rafy; using StackExchange.Redis; using System; using System.Co ...

  3. MySQL高级特性之分区表

    对于用户而言,分区表是一个独立的逻辑表,但是在底层由多个物理子表组成.实现分区的代码实际上是对一组底层表的句柄对象的封装,对分区表的请求都会通过句柄对象转化成对存储引擎的接口调用 意义 MySQL在创 ...

  4. Python re 模块

    Python re 模块 TOC 介绍 作用 正则表达式语法 贪婪和非贪婪 普通字符和特殊字符 分组(比较重要) re modul level 方法 正则表达式对象 匹配对象 常用例子 注意事项 Ja ...

  5. Ext中setVersion和getVersion

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/ ...

  6. 安装PackageControl

    安装PackageControl 1,到PackageControl官网,查找到相应sublime text的版本安装信息, sublime text 3: import urllib.request ...

  7. CSS常见的中属性级,选择符级的Hack

    注意:尽量找到通用方法而减少对CSS Hack的使用,大规模使用CSS Hack会带来维护成本的提高以及浏览器版本变化而带来类似Hack失效等系列问题. 星号 * 针对IE6,7:下划线 _ 针对ie ...

  8. RelativeLayout设置wrap_content无效

    尊重劳动成果,转载请标明出处:http://www.cnblogs.com/tangZH/p/8419053.html 在做项目的过程中,遇到了一个奇怪的现象,我设置RelativeLayout为的宽 ...

  9. 面板JPanel,滚动面板JScrollPane,文本域JTextArea

    [面板JPanel] 面板就是一个容器 每一个容器都可以有一个自己的独立的布局和组件,这些容器之间也不会互相干扰 //导入Java类 import javax.swing.*; import java ...

  10. linux下执行QT可执行文件报错

    老样子,不多BiBi,直接进入主题! 有时候在linux下编译好QT程序,用QTCreator运行没问题,打包移植到另一台机器上,用命令./XX执行就会报错:error while loading s ...