How To Pass Memory Limit for this Solution
Difference between en1 and en2, changed 230 character(s)
[Problem](https://mirror.codeforces.com/problemset/problem/1181/D)contest/1181/problem/D↵

Data Structure used↵

First  ,of all I have calculated number of times a city has hosted olympiad↵
second ,I have associated all cites which have hosted same number of times↵


~~~~~

`//JSD↵
#include<iostream>↵
#include<set>↵
#include<vector>↵
#define ll long long ↵
#include<map>↵
using namespace std;↵
int main(){↵
int n,m,q,a;↵
ios_base::sync_with_stdio(false);↵
cin.tie(NULL);↵
cin>>n>>m>>q;↵
int Freq[m+1]={0};↵
for(int i=0;i<n;i++){↵
cin>>a;↵
Freq[a]++;↵
}↵
int maa=0;↵
for(int i=0;i<=m;i++){↵
maa=max(maa,Freq[i]);↵
}↵
vector<int > mpq[maa+1];↵
for(int i=1;i<=m;i++){↵
mpq[Freq[i]].push_back(i);↵
}↵
vector<int > ans;↵
int count=0;↵
set<int > s;↵
for(ll i=0;i<=maa;i++){↵
for(auto x: mpq[i]){↵
s.insert(x);↵
}↵
for(auto x: s){↵
ans.push_back(x);↵
}↵
}↵
while(q--){↵
ll p;↵
cin>>p;↵
p-=(n+1);↵
if(p<ans.size()){↵
cout<<ans[p];↵
}↵
else{↵
cout<<(p-ans.size())%m+1;↵
}↵
cout<<"\n";↵
}↵
return 0;↵
}
`
~~~~~↵

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English nipul1 2019-06-16 18:56:01 230
en1 English nipul1 2019-06-16 18:47:31 888 Initial revision (published)