Submission #801115

#TimeUsernameProblemLanguageResultExecution timeMemory
801115vjudge1Intercastellar (JOI22_ho_t1)C++17
100 / 100
109 ms30528 KiB
#include <bits/stdc++.h> using namespace std; #define TL ios::sync_with_stdio(0),cin.tie(0),cout.tie(0); #define rall(s) s.rbegin(),s.rend() #define all(s) s.begin(),s.end() #define pb push_back #define fi first #define se second #define ll long long #define ld long double #define YES cout<<"YES\n" #define Yes cout<<"Yes\n" #define yes cout<<"yes\n" #define NO cout<<"NO\n" #define No cout<<"No\n" #define no cout<<"no\n" const int N = 5e5 + 9 , mod = 1e9 + 7; ll d[N] = {} , a[N] = {}, dp[N] = {}, b[N] , c[N]; vector<int>v[N] , v1[N]; void solve(){ ll q , i , j , m ,n, z , s = 0, f, l , r , k , x , y , mn = 1e18 , mx = -1; cin>>n; for(i = 1; i <= n; i++) cin>>a[i]; vector<pair<int,int>>v; b[0] = 1; for(i = 1; i <= 40; i++) b[i] = b[i - 1] * 2; for(i = 1; i <= n; i++){ for(j = 0; j <= 40; j++) if((a[i] % b[j]) != 0){ k = j - 1; break; } v.pb({a[i] / b[k] , b[k]}); } i = 0; for(auto to : v) i++ , c[i] = c[i - 1] + to.se; cin>>q; while(q--){ cin>>k; l = 1; r = n; while(l != r){ m = (l + r) / 2; if(c[m] >= k) r= m; else l = m + 1; } cout<<v[l - 1].fi<<"\n"; } } int main(){ TL; /* #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif */ int t = 1; //cin>>t; while(t--) { solve(); } } // Author : حسن

Compilation message (stderr)

Main.cpp: In function 'void solve()':
Main.cpp:31:26: warning: unused variable 'z' [-Wunused-variable]
   31 |     ll q , i , j , m ,n, z , s  = 0, f, l , r , k , x , y , mn  = 1e18 , mx = -1;
      |                          ^
Main.cpp:31:30: warning: unused variable 's' [-Wunused-variable]
   31 |     ll q , i , j , m ,n, z , s  = 0, f, l , r , k , x , y , mn  = 1e18 , mx = -1;
      |                              ^
Main.cpp:31:38: warning: unused variable 'f' [-Wunused-variable]
   31 |     ll q , i , j , m ,n, z , s  = 0, f, l , r , k , x , y , mn  = 1e18 , mx = -1;
      |                                      ^
Main.cpp:31:53: warning: unused variable 'x' [-Wunused-variable]
   31 |     ll q , i , j , m ,n, z , s  = 0, f, l , r , k , x , y , mn  = 1e18 , mx = -1;
      |                                                     ^
Main.cpp:31:57: warning: unused variable 'y' [-Wunused-variable]
   31 |     ll q , i , j , m ,n, z , s  = 0, f, l , r , k , x , y , mn  = 1e18 , mx = -1;
      |                                                         ^
Main.cpp:31:61: warning: unused variable 'mn' [-Wunused-variable]
   31 |     ll q , i , j , m ,n, z , s  = 0, f, l , r , k , x , y , mn  = 1e18 , mx = -1;
      |                                                             ^~
Main.cpp:31:74: warning: unused variable 'mx' [-Wunused-variable]
   31 |     ll q , i , j , m ,n, z , s  = 0, f, l , r , k , x , y , mn  = 1e18 , mx = -1;
      |                                                                          ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...