Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*----------------------- Directives -----------------------*/
- #include <bits/stdc++.h>
- /*----------------------- Namespaces -----------------------*/
- using namespace std;
- /*----------------------- Macros -----------------------*/
- #define endl '\n'
- #define pb push_back
- #define pf push_front
- #define mem(a,i) memset(a,i,sizeof(a))
- #define ff first
- #define ss second
- #define all(v) v.begin(),v.end()
- #define rall(v) v.rbegin(),v.rend()
- #define w(t) int t=1,tc=1;cin>>t;while(t--)
- /*----------------------- Type Definitions -----------------------*/
- typedef long long ll;
- typedef unsigned long long ull;
- typedef long double ld;
- /*----------------------- Maths -----------------------*/
- const int MOD = 1000*1000*1000 + 7; // for big mod
- template <typename T> inline T gcd(T a, T b){T c;while (b){c = b;b = a % b;a = c;}return a;} // better than __gcd
- template <typename T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
- template <typename T> inline bool isPrime(T n){for (T i=2;i*i<=n;i++) if(n%i==0) return false; return true;}
- vector<bool> prime;
- template <typename T> vector<T> sieve(T n) {
- prime.resize(n+2,true);
- prime[0]=false; prime[1]=false; prime[2]=true;
- vector<T> a;
- for (T i=2;i*i<=prime.size();i++) if (prime[i]) for (T j=i*i;j<prime.size();j+=i) prime[j]=false;
- for (T i=2;i<prime.size();i++) if (prime[i]) a.pb(i);
- return a;
- }
- /*----------------------- SOLVE -----------------------*/
- void solve() {
- int n;
- cin>>n;
- vector<int> v(n);
- multiset<int> mp;
- for (auto &i:v) cin>>i,mp.insert(i);
- for (int i=0;i<n;i++) {
- mp.erase(mp.find(v[i]));
- auto it=mp.upper_bound(2*v[i]);
- if (it==mp.begin()) cout<<-1<<" ";
- else cout<<*(--it)<<" ";
- mp.insert(v[i]);
- }
- cout<<endl;
- }
- int main() {
- ios_base::sync_with_stdio(false);
- cin.tie(NULL);
- // vector<ll> primes = sieve((ll)1e5);
- w(t) {
- cout<<"Case #"<<tc<<": ";
- solve();
- tc++;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement