Submission

Status:

PPPPPPPPPPPPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: anonymous

Problemset: cedt_ovb68_q04

Language: cpp

Time: 0.021 second

Submitted On: 2026-10-07 11:03:56

#include <bits/stdc++.h>
using namespace std;

int count(int n, int u, int v) {

    int first = (n - 1) / u + 1;
    int second = (n - 1) / v + 1;

    return min(first, second);
}

double median(vector<long long> a) {
    int n = a.size();

    if (n % 2 == 1) return a[n / 2];
    else return (a[n / 2 - 1] + a[n / 2]) / 2.0;
}

int main(){
	int n,u,v; cin >> n >> u >> v;
	vector<long long> fav(n);
	
	int k = count(n,u,v);
	for(int i=0;i<n;i++){cin >> fav[i];}
	
	vector<long long> first;
   	vector<long long> second;

   	long double sum = 0;
	
	for(int i=0;i<k;i++)
	{
		int pos1 = i * u;
      	int pos2 = n - 1 - i * v;
		  
		first.push_back(fav[pos1]);
       second.push_back(fav[pos2]);
	   
       sum += (long double)(fav[pos1] * fav[pos2]);
	}
	
	double price,med1,med2;
	price = sum/k;
	med1 = median(first);
	med2 = median(second);
	cout << fixed << setprecision(2);
	cout << price << ' ' << med1 << ' ' << med2;
    return 0;

}