Submission #1296207

#TimeUsernameProblemLanguageResultExecution timeMemory
1296207thaibeo123Intercastellar (JOI22_ho_t1)C++20
100 / 100
53 ms5384 KiB
#include <bits/stdc++.h> using namespace std; #define NAME "A" #define ll long long #define fi first #define se second #define pb push_back #define all(x) x.begin(), x.end() #define MASK(x) (1ll << (x)) #define BIT(x, i) (((x) >> (i)) & 1) const int N = 2e5 + 5; int n, q; ll pre[N]; pair<int, int> b[N]; pair<int, int> odd(int x) { int len = 1; while (x % 2 == 0) { len *= 2; x /= 2; } return {len, x}; } void input() { cin >> n; for (int i = 1; i <= n; i++) { int x; cin >> x; b[i] = odd(x); pre[i] = pre[i - 1] + b[i].fi; } } void solve() { cin >> q; while (q--) { ll pos; cin >> pos; int x = lower_bound(pre + 1, pre + 1 + n, pos) - pre; cout << b[x].se << "\n"; } } signed main() { if (fopen(NAME".INP", "r")) { freopen(NAME".INP", "r", stdin); freopen(NAME".OUT", "w", stdout); } cin.tie(0)->sync_with_stdio(0); int t = 1; //cin >> t; while (t--) { input(); solve(); } return 0; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:50:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   50 |         freopen(NAME".INP", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:51:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   51 |         freopen(NAME".OUT", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...