Submission #847796

#TimeUsernameProblemLanguageResultExecution timeMemory
847796StefanSebezIntercastellar (JOI22_ho_t1)C++14
100 / 100
81 ms10836 KiB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n;
    scanf("%lld",&n);
    ll a[n+1],b[n+1],pref[n+1]={0};
    for(int i=1;i<=n;i++)
	{
		b[i]=1;
		scanf("%lld",&a[i]);
		while(a[i]%2==0){b[i]*=2;a[i]/=2;}
		pref[i]=pref[i-1]+b[i];
	}
    ll q;
    scanf("%lld",&q);
    while(q--)
	{
		ll x;
		scanf("%lld",&x);
		ll lb=lower_bound(pref+1,pref+n+1,x)-pref;
		printf("%lld\n",a[lb]);
	}
    return 0;
}

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:7:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |     scanf("%lld",&n);
      |     ~~~~~^~~~~~~~~~~
Main.cpp:12:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |   scanf("%lld",&a[i]);
      |   ~~~~~^~~~~~~~~~~~~~
Main.cpp:17:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |     scanf("%lld",&q);
      |     ~~~~~^~~~~~~~~~~
Main.cpp:21:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |   scanf("%lld",&x);
      |   ~~~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...