Submission #1123746

#TimeUsernameProblemLanguageResultExecution timeMemory
1123746Neco_arcIntercastellar (JOI22_ho_t1)C++20
100 / 100
71 ms5448 KiB
#include <bits/stdc++.h> #define ll long long #define name "Intercastellar" #define fi(i, a, b) for(int i = a; i <= b; ++i) #define fid(i, a, b) for(int i = a; i >= b; --i) #define maxn (int) (2e5 + 7) using namespace std; int n; ll s[maxn], a[maxn]; void solve() { cin >> n; fi(i, 1, n) { int x, sl = 1; cin >> x; while(x % 2 == 0) sl *= 2, x /= 2; s[i] = s[i - 1] + sl, a[i] = x; } int q; cin >> q; fi(i, 1, q) { ll x; cin >> x; int it = lower_bound(s + 1, s + 1 + n, x) - s; cout << a[it] << '\n'; } } int main() { ios_base::sync_with_stdio(false); cin.tie(0), cout.tie(0); if(fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); } solve(); }

Compilation message (stderr)

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