'solved' climbing the leaderboard

Signed-off-by: ayham <altffour@protonmail.com>
This commit is contained in:
ayham 2021-05-09 12:11:08 +03:00
parent 872debb688
commit 752323464f
No known key found for this signature in database
GPG Key ID: 81D38F7122AFCC94
1 changed files with 20 additions and 0 deletions

View File

@ -0,0 +1,20 @@
#include <stack>
#include <iostream>
using namespace std;
int main(){
unsigned long n, m, i, tmp;
cin >> n;
stack<unsigned long> scores;
for (i = 0; i < n; ++i) {
cin >> tmp;
if (scores.empty() || scores.top() != tmp) scores.push(tmp);
}
cin >> m;
for (i = 0; i < m; ++i) {
cin >> tmp;
while (!scores.empty() && tmp >= scores.top()) scores.pop();
cout << (scores.size() + 1) << endl;
}
return 0;
}