abc190_b - Magic 3

For each monster test if it will yield damage.

Time complexity: $O(n)$

Memory complexity: $O(n)$

Click to show code.


using namespace std;
using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
int main(void)
{
    ios::sync_with_stdio(false), cin.tie(NULL);
    int n, s, d;
    cin >> n >> s >> d;
    ll ans = 0;
    for (int i = 0; i < n; ++i)
    {
        int x, y;
        cin >> x >> y;
        if (x < s and y > d)
            ans += y;
    }
    cout << (ans > 0 ? "Yes" : "No") << endl;
    return 0;
}