728x90
반응형
15577 prosjek
문제풀이
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
void fast_io(void)
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
float q,n;
vector<float> v;
int main(void)
{
fast_io();
cin >>q;
for(int i=0;i<q;i++)
{
int a;
cin >> a;
v.push_back(a);
}
sort(v.begin(),v.end());
for(int i=1;i<q;i++)
{
if(i==1)
n=(v[i-1]+v[i])/2;
else
n=(n+v[i])/2;
}
printf("%f",n);
}
정렬 한뒤 평균을 더해주며 나아갔다.
728x90
반응형
'자라는 개발자 > 문제풀이' 카테고리의 다른 글
백준 c++ 9933 민균이의 비밀번호 (0) | 2022.08.08 |
---|---|
백준 c++ 11645 I've Been Everywhere, Man (0) | 2022.07.23 |
백준 c++ 21194 Meditation (0) | 2022.07.11 |
백준 c++ 7795 먹을 것인가 먹힐 것인가 (0) | 2022.07.10 |
백준 c++ 20920 영단어 암기는 괴로워 (0) | 2022.07.04 |