Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <map>
- #include <set>
- #include <list>
- #include <cmath>
- #include <ctime>
- #include <deque>
- #include <queue>
- #include <stack>
- #include <string>
- #include <bitset>
- #include <cstdio>
- #include <limits>
- #include <vector>
- #include <climits>
- #include <cstring>
- #include <cstdlib>
- #include <fstream>
- #include <numeric>
- #include <sstream>
- #include <iostream>
- #include <algorithm>
- #include <unordered_map>
- using namespace std;
- int main() {
- int n, a, b, t, q;
- cin >> n;
- vector<pair<int, int>> products; //id time
- unordered_map<int, int> quality; //id count
- map<int, int> answears; // time, most sell id
- int max = 0;
- int maxId = -1;
- for(int i = 0; i < n; i++){
- cin >> a >> b;
- quality[a]++;
- if(quality[a] >= max){
- max = quality[a];
- maxId = a;
- answears[b] = maxId;
- }
- }
- answears[0] = -1;
- cin >> t;
- for(int i = 0; i < t; i++){
- cin >> a;
- pair<int, int> find = *(--answears.upper_bound(a));
- cout << find.second << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment