Submission

Status:

PP--PPP-P-

Subtask/Task Score:

60/100

Score: 60

User: anonymous

Problemset: ค่าแปลกๆ

Language: cpp

Time: 0.003 second

Submitted On: 2026-10-21 21:04:10

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

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n; cin >> n;
    vector<pair<int, int >> 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;
}