Official

B - Trifecta Editorial by en_translator


Original proposer: admin

If we are asked the times instead of the numbers, we may simply sort \(T_i\). In case we are asked the numbers, as in this problem, we may sort pairs \((T_i,i)\) to find the answers.

Sample code (Python)

N=int(input())
T=list(map(int,input().split()))

TI=[]
for i in range(N):
  TI.append((T[i],i+1))

TI.sort()
print(TI[0][1], TI[1][1], TI[2][1])

Sample code (C++)

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

int main(){
	int n;
	cin >> n;

	vector<pair<int,int>>ti;
	for(int i=0;i<n;i++){
		int t;
		cin >> t;
		ti.push_back({t,i+1});
	}

	sort(ti.begin(),ti.end());
	cout << ti[0].second << ' ' << ti[1].second << ' ' << ti[2].second << endl;
}

posted:
last update: