Advertisement
Alexandre_lsv

Untitled

Mar 6th, 2016
290
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.05 KB | None | 0 0
  1. #include <iostream>
  2. #include <list>
  3. #include <algorithm>
  4. #include <fstream>
  5. #include <cmath>
  6. #include <cstdlib>
  7. #include <iomanip>
  8. #include <map>
  9. #include <set>
  10. #define eps 0.1
  11. using namespace std;
  12. long long prod(long long x){
  13.     long long t=0;
  14.     long long res=1;
  15.     while(true){
  16.         res*=x%10;
  17.         x/=10;
  18.         if (x==0)
  19.             break;
  20.     }
  21.     return res;
  22. }
  23. int main()
  24. {
  25.     //ifstream fin("file.in");
  26.     //ofstream fout("file.out");
  27.     long long n, m;
  28.     long long max=0;
  29.     long long ress=0;
  30.     long long maxi=0;
  31.     map<int, int> mapp;
  32.     int mass[10000]={};
  33.     int mas1[500200]={};
  34.     int mas[500200]={};
  35.  
  36.     cin.sync_with_stdio(false);
  37.     cin >> n;
  38.     for (int i=0; i<n; i++){
  39.         cin >> m;
  40.         mass[i]=m;
  41.     }/*
  42.         bool bmas[1000000]={};
  43.         for (int j=0; j<n; j++)
  44.         {
  45.             if (!bmas[j]){
  46.                 for (int k=j+1; k<n; k++){
  47.                     if (!bmas[k]){
  48.                         mas[mass[j]+mass[k]]++;
  49.                         //bmas[k]=true;
  50.                         //cout << mass[j]+mass[k] << endl;
  51.                     }
  52.                 }
  53.             }
  54.         }*/
  55.         int ressmas=0;
  56.  
  57.         set<int> sett;
  58.          for (int j=0; j<n; j++)
  59.             {
  60.                     for (int k=j+1; k<n; k++){
  61.                        
  62.                                 sett.insert(mass[k]+mass[j]);
  63.                                 mas1[mass[k]+mass[j]]++;
  64.                            
  65.                        
  66.                     }
  67.            
  68.             }
  69.     int res1=0;
  70.     int sr=0;
  71.     for (auto&i:sett) {
  72.         sr+=mas1[i];
  73.     }
  74.     sr/=sett.size();
  75.     for (auto&i:sett) {
  76.         if (mas1[i]>=sr){
  77.             bool bmas1[1000000]={};
  78.             //cout << ressmas;
  79.             for (int j=0; j<n; j++)
  80.                 {
  81.                     if (!bmas1[j]){
  82.                         for (int k=j+1; k<n; k++){
  83.                             if (!bmas1[k]&&!bmas1[j]){
  84.                                 if (mass[j]+mass[k]==i){
  85.                                     mas[i]++;
  86.                                     bmas1[k]=true;
  87.                                     bmas1[j]=true;
  88.                                 }
  89.                                 //cout << j << ' ' << k << endl;
  90.                             }
  91.                         }
  92.                     }
  93.                 }
  94.             }
  95.         }
  96.      for (auto i:sett)
  97.     {
  98.         if (mas[i]>ress){
  99.             ress=mas[i];
  100.        
  101.             ressmas=i;
  102.         }
  103.     }
  104.     cout << ress << endl;
  105.     //fin.close();
  106.     //fout.close();
  107.     return 0;
  108. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement