Submission

Status:

PPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: anonymous

Problemset: ค่าแปลกๆ

Language: cpp

Time: 0.003 second

Submitted On: 2026-10-21 21:05:46

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

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    long long n; cin >> n;
    vector<pair<long long, long long >> num(n);
    long long total = 0;
    for(int i=0;i<n;i++){
        cin >> num[i].first;
        total += num[i].first;
    }

    for(int i=0;i<n;i++) num[i].second = abs(total - num[i].first*n);

    sort(num.begin(),num.end(),[](const pair<long long, long long>&a,const pair<long long, long long>&b){
        if(a.second != b.second) return a.second > b.second;
        return a.first > b.first;
    });

    cout << num[0].first;
}