답안 #671516

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
671516 2022-12-13T06:15:50 Z dooompy Meandian (CEOI06_meandian) C++17
100 / 100
5 ms 208 KB
#include "libmean.h"
#include <bits/stdc++.h>

using namespace std;

int n;

int ans[1005];

void find5(vector<int> idx) {

    vector<pair<int, int>> total;

    for (int i = 0; i < 5; i++) {

        vector<int> temp;
        
        for (int j = 0; j < 5; j++) {
            if (i == j) continue;
            temp.push_back(idx[j])  ;    
        }

        int res = Meandian(temp[0], temp[1], temp[2], temp[3]);

        total.push_back({res * 2, i});
    }

    sort(total.begin(), total.end());

    int mid = total[0].first + total[4].first - total[2].first;
    mid /= 2;

    ans[idx[total[2].second] - 1] = mid;

    return;
}

int main()
{
    n = Init();

    fill(ans, ans+1005, -1);

    for (int t = 1; t <= n; t++) {
        vector<int> temp;
        for (int i = 0; i < n; i++) {
            if (ans[i] == -1) {
                temp.push_back(i + 1);
            }

            if (temp.size() == 5) break;
        }
      
      if (temp.size() != 5) break;

        find5(temp);
    }

    Solution(ans);

} 
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 2 ms 208 KB Output is correct
7 Correct 3 ms 208 KB Output is correct
8 Correct 4 ms 208 KB Output is correct
9 Correct 5 ms 208 KB Output is correct
10 Correct 4 ms 208 KB Output is correct