# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1266619 | tminh | Intercastellar (JOI22_ho_t1) | C++20 | 44 ms | 5448 KiB |
#include "bits/stdc++.h"
using namespace std;
#define task ""
#define ll long long
#define endl '\n'
#define fi first
#define se second
#define vall(a) (a).begin(), (a).end()
#define sze(a) (int)a.size()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ep emplace_back
#define pb push_back
#define pf push_front
const ll mod = 1e9 + 7;
const int N = 1e6 + 5;
const ll oo = 1e18;
bool START;
// so lan doc sol roi moi biet lam :
ll n, a[N], q, pos[N];
inline void solve() {
for (int i = 1; i <= n; ++i) {
ll cur = 1;
while(!(a[i] & 1)) {
a[i] >>= 1;
cur <<= 1ll;
}
// cout << a[i] << " " << cur << endl;
pos[i] = pos[i - 1] + cur;
}
while(q--) {
ll x;
cin >> x;
auto it = lower_bound(pos + 1, pos + 1 + n, x) - pos;
cout << a[it] << endl;
}
}
inline void input() {
cin >> n;
for (int i = 1; i <= n; ++i) cin >> a[i];
cin >> q;
return solve();
}
bool END;
int main() {
if(fopen(task ".inp", "r")) {
freopen(task ".inp", "r", stdin);
freopen(task ".out", "w", stdout);
}
ios_base::sync_with_stdio(false);
cin.tie(nullptr); cout.tie(nullptr);
input();
cerr << endl << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << 's' << endl;
cerr << "Memory: " << fabs ((&END - &START)) / 1048576.0 << "MB\n";
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |