Official
B - Play Snuke Editorial by en_translator
If \(X_i > A_i\), then Takahashi can buy Play Snuke at shop \(i\).
Therefore, it is sufficient to find the minimum \(P_i\) for such shops that \(X_i > A_i\).
Sample Code (C++)
#include <iostream>
using namespace std;
const int INF = 0x3fffffff;
void chmin(int& a, int b){ if(a > b) a = b; }
int main(){
int N;
cin >> N;
int ans = INF;
for(int i = 0; i < N; i++){
int A, P, X;
cin >> A >> P >> X;
if(X > A) chmin(ans, P);
}
if(ans == INF) ans = -1;
cout << ans << endl;
}
Sample Code (Python)
INF = 1 << 30
N = int(input())
ans = INF
for i in range(N):
A, P, X = map(int, input().split())
if X > A and ans > P:
ans = P
if ans == INF:
ans = -1
print(ans)
posted:
last update: