No Rules Rules

solved.ac (feat. 백준, 18110번) 본문

생활/코테

solved.ac (feat. 백준, 18110번)

개발하는 완두콩 2023. 6. 12. 12:02
728x90
반응형

solved.ac
https://www.acmicpc.net/problem/18110

 

18110번: solved.ac

5명의 15%는 0.75명으로, 이를 반올림하면 1명이다. 따라서 solved.ac는 가장 높은 난이도 의견과 가장 낮은 난이도 의견을 하나씩 제외하고, {5, 5, 7}에 대한 평균으로 문제 난이도를 결정한다.

www.acmicpc.net

 

// woohyeon.kim
// kim519620.tistory.com
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
using namespace std;
vector<int> arr;
int main() {
	ios::sync_with_stdio(false), cin.tie(NULL);
    register int N, ans = 0, cnt;
    cin >> N;
    if(N == 0)
        cout << ans;
    else{
        for(register int n = 0, v; n < N; ++n)
            cin >> v, arr.push_back(v);
        cnt = static_cast<int>(round(N * 0.15));
        sort(arr.begin(), arr.end());
        for(register int i = cnt; i < N - cnt; ++i)
            ans += arr[i];
        cout << static_cast<int>(round(ans / (N - 2.0 * cnt)));
    }
	return 0;
}
// *&)*@*

 

반응형

정렬을 통해 연산하는 문제입니다.

728x90
반응형
Comments