Submission #602278

#TimeUsernameProblemLanguageResultExecution timeMemory
602278IvanJIntercastellar (JOI22_ho_t1)C++17
100 / 100
120 ms8552 KiB
#include<bits/stdc++.h>

#define pb push_back
#define x first
#define y second

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;

const int maxn = 2e5 + 5;

int n, q;
int A[maxn];

int main() {
	scanf("%d", &n);
	for(int i = 0;i < n;i++) 
		scanf("%d", A + i);
		
	vector<ii> v;
	for(int i = 0;i < n;i++) {
		int x = A[i] & -A[i];
		v.pb({A[i] / x, x});
	}
	
	ll cnt = 0;
	int pos = 0;
	scanf("%d", &q);
	for(int i = 0;i < q;i++) {
		ll x;
		scanf("%lld", &x);
		while(cnt < x) cnt += v[pos++].y;
		printf("%d\n", v[pos - 1].x);
	}
	return 0;
}

Compilation message (stderr)

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