Submission #718539

#TimeUsernameProblemLanguageResultExecution timeMemory
718539vinnipuh01Intercastellar (JOI22_ho_t1)C++17
100 / 100
84 ms10780 KiB
#include <iostream>
#include <bits/stdc++.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <deque>
#include <set>
#include <stack>
#include <string>
#include <map>
#include <queue>
#define int long long
#define sqrt sqrtl

using namespace std;

const long long oo = 1000000000000000000;

long long sum, ans = 0, mx = 0, mn = 1000000000, num, pos;


/*
    ViHHiPuh

   (( `'-""``""-'` ))
     )-__-_.._-__-(
   / --- (o _ o) --- \
   \ .-* ( .0. ) *-. /
   _'-. ,_ '=' _, .-'_
  / `;#'#'# - #'#'#;` \
 \_)) -----'#'----- ((_/
      # --------- #
  '# ------- ------ #'
  /..-'# ------- #'-.\
  _\...-\'# -- #'/-.../_
  ((____)- '#' -(____))


    cout << fixed << setprecision(6) << x;


    freopen ( "sum.in", "r", stdin )
*/

int n, a[ 200001 ], q, x, b[ 200001 ], p[ 200001 ];

main () {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> n;
    for ( int i = 1; i <= n; i ++ ) {
    	cin >> a[ i ];
    	b[ i ] = 1;
    	while ( a[ i ] % 2 == 0 ) {
    		b[ i ] *= 2;
    		a[ i ] /= 2;
		}
		p[ i ] = p[ i - 1 ] + b[ i ];
	}
	cin >> q;
	while ( q -- ) {
		cin >> x;
		int l, r, mid;
		l = 1;
		r = n;
		while ( r > l ) {
			mid = ( r + l ) / 2;
			if ( p[ mid ] >= x )
				r = mid;
			else
				l = mid + 1;
		}
		cout << a[ l ] << "\n";
	}
}

Compilation message (stderr)

Main.cpp:47:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   47 | main () {
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...