Pearlfromsu

st170321_26

Mar 24th, 2021 (edited)
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.20 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <algorithm>
  4. #include <vector>
  5.  
  6. using namespace std;
  7.  
  8. int main() {//23:42
  9.     ifstream f("C:/inp/st170321/26/26.txt");
  10.     int n;
  11.     f >> n;
  12.     vector<long> aa(n);
  13.  
  14.     for (int i = 0; i < n; i++) {
  15.         f >> aa[i];
  16.     }
  17.     sort(aa.begin(), aa.end());
  18.  
  19.     int cnt = 0;
  20.     long maxx = 0;
  21.  
  22.     for (int i = 0; i < n; i++) { //0 1 2 3 4 5 6
  23.         if (aa[i] % 2 != 0) //нечётное
  24.             continue;
  25.         for (int j = n - 1; j > i + 1; j--) {
  26.             if (aa[j] % 2 != 0) //нечётное
  27.                 continue;
  28.             long mid = (i + j) / 2;
  29.             long srr = (aa[i] + aa[j]) / 2;
  30.             if (aa[mid] == srr) {
  31.                 cnt++;
  32.                 if (srr > maxx)
  33.                     maxx = srr;
  34.                 continue;
  35.             }
  36.             int k = mid;
  37.             if (aa[mid] > srr) {
  38.                 while (aa[k] > srr) {
  39.                     k--;
  40.                 }
  41.                 if (aa[k] == srr) {
  42.                     cnt++;
  43.                     if (srr > maxx)
  44.                         maxx = srr;
  45.                     continue;
  46.                 }
  47.             }
  48.             if (aa[mid] < srr) {
  49.                 while (aa[k] > srr) {
  50.                     k++;
  51.                 }
  52.                 if (aa[k] == srr) {
  53.                     cnt++;
  54.                     if (srr > maxx)
  55.                         maxx = srr;
  56.                     continue;
  57.                 }
  58.             }
  59.         }
  60.         cout << "procccccccc " << i << "/" << n << " " << cnt << " " << maxx << endl;
  61.     }
  62.     cout << cnt << " " << maxx << endl; //00:13
  63.    
  64.     return 0;
  65. }
  66.  
  67.  
Add Comment
Please, Sign In to add comment