Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
442 B
2
Indexable
Never
#include <iostream>
using namespace std;

int main()
{
    int count, age, pol, max = 0, number = 0, i, g = 1;
    cin >> count;
    for (i = 1; i <= count; i++)
    {
        cin >> age;
        cin >> pol;
        if (pol == 1 and age > max)
        {
            max = age;
            number = i;
        }
        if (pol != 1) g++;
    }
    if (i == g) cout << "-1" << endl;
    else cout << number << endl;
    
}