Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <algorithm>
- #include <vector>
- using namespace std;
- int main() {//23:42
- ifstream f("C:/inp/st170321/26/26.txt");
- int n;
- f >> n;
- vector<long> aa(n);
- for (int i = 0; i < n; i++) {
- f >> aa[i];
- }
- sort(aa.begin(), aa.end());
- int cnt = 0;
- long maxx = 0;
- for (int i = 0; i < n; i++) { //0 1 2 3 4 5 6
- if (aa[i] % 2 != 0) //нечётное
- continue;
- for (int j = n - 1; j > i + 1; j--) {
- if (aa[j] % 2 != 0) //нечётное
- continue;
- long mid = (i + j) / 2;
- long srr = (aa[i] + aa[j]) / 2;
- if (aa[mid] == srr) {
- cnt++;
- if (srr > maxx)
- maxx = srr;
- continue;
- }
- int k = mid;
- if (aa[mid] > srr) {
- while (aa[k] > srr) {
- k--;
- }
- if (aa[k] == srr) {
- cnt++;
- if (srr > maxx)
- maxx = srr;
- continue;
- }
- }
- if (aa[mid] < srr) {
- while (aa[k] > srr) {
- k++;
- }
- if (aa[k] == srr) {
- cnt++;
- if (srr > maxx)
- maxx = srr;
- continue;
- }
- }
- }
- cout << "procccccccc " << i << "/" << n << " " << cnt << " " << maxx << endl;
- }
- cout << cnt << " " << maxx << endl; //00:13
- return 0;
- }
Add Comment
Please, Sign In to add comment