Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <list>
- #include <algorithm>
- #include <fstream>
- #include <cmath>
- #include <cstdlib>
- #include <iomanip>
- #include <map>
- #include <set>
- #define eps 0.1
- using namespace std;
- long long prod(long long x){
- long long t=0;
- long long res=1;
- while(true){
- res*=x%10;
- x/=10;
- if (x==0)
- break;
- }
- return res;
- }
- int main()
- {
- //ifstream fin("file.in");
- //ofstream fout("file.out");
- long long n, m;
- long long max=0;
- long long ress=0;
- long long maxi=0;
- map<int, int> mapp;
- int mass[10000]={};
- int mas1[500200]={};
- int mas[500200]={};
- cin.sync_with_stdio(false);
- cin >> n;
- for (int i=0; i<n; i++){
- cin >> m;
- mass[i]=m;
- }/*
- bool bmas[1000000]={};
- for (int j=0; j<n; j++)
- {
- if (!bmas[j]){
- for (int k=j+1; k<n; k++){
- if (!bmas[k]){
- mas[mass[j]+mass[k]]++;
- //bmas[k]=true;
- //cout << mass[j]+mass[k] << endl;
- }
- }
- }
- }*/
- int ressmas=0;
- set<int> sett;
- for (int j=0; j<n; j++)
- {
- for (int k=j+1; k<n; k++){
- sett.insert(mass[k]+mass[j]);
- mas1[mass[k]+mass[j]]++;
- }
- }
- int res1=0;
- int sr=0;
- for (auto&i:sett) {
- sr+=mas1[i];
- }
- sr/=sett.size();
- for (auto&i:sett) {
- if (mas1[i]>=sr){
- bool bmas1[1000000]={};
- //cout << ressmas;
- for (int j=0; j<n; j++)
- {
- if (!bmas1[j]){
- for (int k=j+1; k<n; k++){
- if (!bmas1[k]&&!bmas1[j]){
- if (mass[j]+mass[k]==i){
- mas[i]++;
- bmas1[k]=true;
- bmas1[j]=true;
- }
- //cout << j << ' ' << k << endl;
- }
- }
- }
- }
- }
- }
- for (auto i:sett)
- {
- if (mas[i]>ress){
- ress=mas[i];
- ressmas=i;
- }
- }
- cout << ress << endl;
- //fin.close();
- //fout.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement