Codeforces#543 div2 B. Mike and Children(暴力?)
题目链接:http://codeforces.com/problemset/problem/1121/B
题意 给n个数 最多的对数 其中每一对(i,j)的ai+aj都相等(不知道怎么解释。。。。
判断的话 大概是4重循环 因为每次都选4个数嘛 两两相加判等 不过会TLE 而且并不知道哪些值用了哪些没用
就可以预处理记录a[i]+a[j]出现的次数 然后排序找最大的就好了
代码有点鬼畜。。
代码如下
#include <cstdio>
#include <algorithm>
#include <map>
#include <vector>
using namespace std; const int maxn = ;
int a[maxn];
map<int, int> mp;
vector<int> G; int main() {
int n;
scanf("%d", &n);
for (int i = ; i < n; i++) {
scanf("%d", &a[i]);
}
for (int i = ; i < n; i++) {
for (int j = i + ; j < n; j++) {
mp[a[i] + a[j]]++;
G.push_back(a[i] + a[j]);
}
}
int ans = -;
for (int i = , sz = G.size(); i < sz; i++) {
if (mp[G[i]] > ans) ans = mp[G[i]];
}
printf("%d\n", ans);
return ;
}
Codeforces#543 div2 B. Mike and Children(暴力?)的更多相关文章
- Codeforces#543 div2 A. Technogoblet of Fire(阅读理解)
题目链接:http://codeforces.com/problemset/problem/1121/A 真·阅读理解 题意就是 有n个人 pi表示他们的强度 si表示他们来自哪个学校 现在Arkad ...
- codeforces 351 div2 C. Bear and Colors 暴力
C. Bear and Colors time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- codeforces 9 div2 C.Hexadecimal's Numbers 暴力打表
C. Hexadecimal's Numbers time limit per test 1 second memory limit per test 64 megabytes input stand ...
- Codeforces #180 div2 C Parity Game
// Codeforces #180 div2 C Parity Game // // 这个问题的意思被摄物体没有解释 // // 这个主题是如此的狠一点(对我来说,),不多说了这 // // 解决问 ...
- Codeforces #541 (Div2) - E. String Multiplication(动态规划)
Problem Codeforces #541 (Div2) - E. String Multiplication Time Limit: 2000 mSec Problem Descriptio ...
- Codeforces #541 (Div2) - F. Asya And Kittens(并查集+链表)
Problem Codeforces #541 (Div2) - F. Asya And Kittens Time Limit: 2000 mSec Problem Description Inp ...
- Codeforces #541 (Div2) - D. Gourmet choice(拓扑排序+并查集)
Problem Codeforces #541 (Div2) - D. Gourmet choice Time Limit: 2000 mSec Problem Description Input ...
- Codeforces #548 (Div2) - D.Steps to One(概率dp+数论)
Problem Codeforces #548 (Div2) - D.Steps to One Time Limit: 2000 mSec Problem Description Input Th ...
- 【Codeforces #312 div2 A】Lala Land and Apple Trees
# [Codeforces #312 div2 A]Lala Land and Apple Trees 首先,此题的大意是在一条坐标轴上,有\(n\)个点,每个点的权值为\(a_{i}\),第一次从原 ...
随机推荐
- Python脱产8期 Day05 2019/4/17
数据类型的使用 一 数字类型 1.整型:int 2.浮点型:float 3.重点:数字类型直接相互转化 二字符串类型 一 1.定义:在单引号/双引号/三引号中包含一系列字符. 2.注意:可以通过引号的 ...
- 环境部署(五):Linux下安装Gradle
Gradle是一个基于Apache的Ant和Maven的项目自动化构建工具,相比于Ant和Maven的局限性,Gradle可以更好的帮助管理项目中的差异.依赖.编译.打包.部署. 可以自定义满足自己需 ...
- 两个select之间的元素互相移动并保持顺序
<html> <head> <meta http-equiv="Content-Type" content="text/html; char ...
- hibernate 解决诡异的mysql存入中文乱码
使用hibernate查询mysql,通过bean的get方法拿到字符串再写入mysql中的字段会中文乱码,需要String string = xxx.get(),把get方法拿到的值传入到新的str ...
- JSF生存指南P1
这是OO的第三次博客作业,也是JSFO(面向JSF编程)的第一次博客作业.暗示了我们面向对象课程已经再向JSF的编写过渡. 不知不觉OO的作业已经写完3/4,那些熬夜赶作业的日子仍然历历在目,仿佛是昨 ...
- Jenkins-job之间依赖关系配置
使用场景: 想要在某APP打新包之后,立即执行自动化测试的job来验证该新包. 比如Job A 执行完执行Job B ,如下图所示,如何建立依赖呢? 1.配置上游依赖 构建触发器-配置如下信息: 选择 ...
- Let's-Bug修复日志
Version 1.1 2015/11/16 修复了上传图片画质问题的Bug 修复了搜索功能的部分Bug 增加了下拉刷新的功能 修复了部分界面跳转之间的问题
- p68理想的性质
1.如何由2.2.4推出后面的结论? 2.为什么A可以等于R? 3.如何证明3? π:R->R/M套用定理2.2.4(2)和(1) R2是R/M,I是R/M的理想也就是R2的理想,所以f^(-1 ...
- MySQL左连接时 返回的记录条数 比 左边表 数量多
在学MySQL的连接时,为了便于记忆,就将左连接 记做 最后结果的总记录数 和 进行左连接的左表的记录数相同,简单的说就是下面这个公式 count(table A left join table B) ...
- C#复习笔记(3)--C#2:解决C#1的问题(进入快速通道的委托)
委托 前言:C#1中就已经有了委托的概念,但是其繁杂的用法并没有引起开发者太多的关注,在C#2中,进行了一些编译器上的优化,可以用匿名方法来创建一个委托.同时,还支持的方法组和委托的转换.顺便的,C# ...