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}\),第一次从原 ...
随机推荐
- 20175330 实验一 《Java开发环境的熟悉》实验报告
一.实验内容及步骤 (一)使用JDk编译.运行简单的Java程序 (一)使用JDk编译.运行简单的Java程序 输入cd Code命令进入Code目录 输入mkdir 20175308建立实验目录 l ...
- VBS弹出来的对话框如何置顶!--果然技巧
msgbox 第二参数+4096 mshta vbscript:msgbox("提示内容6",6,"提示窗口6")(window.close)
- MySQL 数据库规范--调优篇(终结篇)
前言 这篇是MySQL 数据库规范的最后一篇--调优篇,旨在提供我们发现系统性能变弱.MySQL系统参数调优,SQL脚本出现问题的精准定位与调优方法. 目录 1.MySQL 调优金字塔理论 2.MyS ...
- OpenResty入门之使用Lua扩展Nginx
记住一点:nginx配置文件很多坑来源自你的空格少了或多了. 1.Centos下载安装 如果你的系统是 Centos 或 RedHat 可以使用以下命令: yum install readline-d ...
- CentOS 6.5下RPM方式(重新)安装MySQL 5.7.21从头到尾篇
强烈推荐参阅这一篇教程 https://www.cnblogs.com/kevingrace/p/8340690.html 下面我写的仅供参考 今天把Mysql5.1升级到了5.7,浪费了一天为了避 ...
- 【深度学习】一文读懂机器学习常用损失函数(Loss Function)
最近太忙已经好久没有写博客了,今天整理分享一篇关于损失函数的文章吧,以前对损失函数的理解不够深入,没有真正理解每个损失函数的特点以及应用范围,如果文中有任何错误,请各位朋友指教,谢谢~ 损失函数(lo ...
- 两次console.log打印值不同
var a=[1,2,3] console.log(a); a[2]=10; console.log(a); // 打印结果 // (3) [1, 2, 3] // (3) [1, 2, 10] // ...
- long long 的输入输出问题
参考博客:https://www.byvoid.com/zhs/blog/c-int64
- elasticSearch聚合sum查询
有时需要统计一段时间内,订单的总金额.类似于sql的sum,针对某一字段求和.这就涉及到es的聚合查询,来看看用spring-data-elasticSearch怎么写: QueryBuilder ...
- semantic-ui 容器与栅格
semantic中可以指定one-sixteen这16个单词来指定网格column所占的长度.也就是说,在网页中,一行最多只有16个column,超过16个之后,自动移到下一行. 栅格可以使用i,di ...