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}\),第一次从原 ...
随机推荐
- Java IO(五)——字符流进阶及BufferedWriter、BufferedReader
一.字符流和字节流的区别 拿一下上一篇文章的例子: package com.demo.io; import java.io.File; import java.io.FileReader; impor ...
- Windows安裝PHP環境
Windows安裝PHP環境的準備工作:httpd-2.2+php-5.4+mysql-5.5 第一步是安裝相對應的三個軟件,只要略懂一些英文單詞,安裝是沒有問題的,所以此處略過三個文件的安裝過程,直 ...
- C#发邮件_EmailHelper
EmailHelper类 public class EmailHelper { /// <summary> /// 发送邮件 /// </summary> /// <pa ...
- 使用keras的LSTM进行预测----实战练习
代码 import numpy as np from keras.models import Sequential from keras.layers import Dense from keras. ...
- 【C#复习总结】多线程编程
1 基本概念 前一篇文章做了铺垫,详见:http://www.cnblogs.com/mhq-martin/p/9035640.html 2 多线程 多线程的优点:可以同时完成多个任务:可以使程序的响 ...
- centos中docker的安装
之前学习docker的时候,是在windows上直接使用可执行文件安装的,最近需要在自己的服务器上安装docker,特此了解了一下如何安装,这里补一下. 小白学Docker之基础篇 小白学Docker ...
- flask 单元测试
程序开发过程中,代码是为了完成需求,当代码编译通过后,能不能保证功能的正常实现,需要我们编写测试代码,模拟程序运行过程,检验功能是否符合预期. 单元测试主要面向一些功能单一的模块进行. 单元测试,实际 ...
- Centos 7 修改系统时区
timedatectl status Local time: 四 2014-12-25 10:52:10 CST Universal time: 四 2014-12-25 02:52:10 UTC R ...
- Ordering Tasks
链接 [https://vjudge.net/contest/281085#problem/D] 题意 有n个任务,有M个对先后顺序 然你输出最后的完成任务的顺序,有多种可能输出一种即可 分析 裸的拓 ...
- l^oo不可分的两个注意点
1 不理解等一个等式 , 2.不理解为什么,一个可分的集合里面有不可数的子集?谢谢 1是 2.是可分集合里面每个元素 做中心后的一个开覆盖 所有0 1序列是和所有二进制小数 可以一一对应 而 ...