제출 #531712

#제출 시각아이디문제언어결과실행 시간메모리
531712errorgornIntercastellar (JOI22_ho_t1)C++17
100 / 100
345 ms9156 KiB
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define ll long long
#define ii pair<ll,ll>
#define fi first
#define se second

#define puf push_front
#define pof pop_front
#define pub push_back
#define pob pop_back
#define lb lower_bound
#define ub upper_bound

#define rep(x,s,e) for (auto x=(s)-((s)>(e));x!=(e)-((s)>(e));((s)<(e))?x++:x--)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int) (x).size()

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

int n,q;
ll arr[200005];
ll cnt[200005];

signed main(){
	cin.tie(0);
	cout.tie(0);
	cin.sync_with_stdio(false);
	
	cin>>n;
	rep(x,1,n+1){
		cin>>arr[x];
		cnt[x]=arr[x]&-arr[x];
		arr[x]/=cnt[x];
	}
	
	rep(x,1,n+1) cnt[x]+=cnt[x-1];
	
	ll a;
	cin>>q;
	while (q--){
		cin>>a;
		
		int lo=0,hi=n,mi;
		while (hi-lo>1){
			mi=hi+lo>>1;
			
			if (a<=cnt[mi]) hi=mi;
			else lo=mi;
		}
		
		cout<<arr[hi]<<endl;
	}
}

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'int main()':
Main.cpp:48:9: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   48 |    mi=hi+lo>>1;
      |       ~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...