Official

B - Magic 3 Editorial by en_translator


It says that the monster is not damaged with a spell taking \(S\) or more seconds to cast or a spell with powers \(D\) or less,
so check if there is a spell taking less than \(S\) seconds and also with powers more than \(D\).

Sample Code (C++)

#include <iostream>
using namespace std;

int main(){
    int N, S, D;
    cin >> N >> S >> D;
    for(int i = 0; i < N; i++){
        int X, Y;
        cin >> X >> Y;
        if(X < S && Y > D){
            puts("Yes");
            return 0;
        }
    }
    puts("No");
}

Sample Code (Python)

N, S, D = map(int, input().split())
def check():
    X, Y = map(int, input().split())
    return X < S and Y > D

if any(check() for i in range(N)):
    print("Yes")
else:
    print("No")

posted:
last update: